home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume91 / utilitys / sman_1_1 / part01 next >
Encoding:
Text File  |  1991-07-29  |  65.7 KB  |  2,759 lines

  1. Path: news.larc.nasa.gov!amiga-request
  2. From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  3. Subject: v91i137: sman 1.1 - a manual type program, Part01/02
  4. Reply-To: "J. Spencer" <bhgs@utcs.utoronto.ca>
  5. Newsgroups: comp.sources.amiga
  6. Message-ID: <comp.sources.amiga.v91i137@ab20.larc.nasa.gov>
  7. Date: 29 Jul 91 22:57:31 GMT
  8. Approved: tadguy@uunet.UU.NET (Tad Guy)
  9. X-Mail-Submissions-To: amiga@uunet.uu.net
  10. X-Post-Discussions-To: comp.sys.amiga.misc
  11.  
  12. Submitted-by: "J. Spencer" <bhgs@utcs.utoronto.ca>
  13. Posting-number: Volume 91, Issue 137
  14. Archive-name: utilities/sman-1.1/part01
  15.  
  16. [ includes uuencoded executable, library, and docs  ...tad ]
  17.  
  18.    The first release (1.0) of these programs was somewhat riddled with
  19. bugs.  I think I've gotten most of the bad ones, at least it seems to
  20. perform as advertised now.
  21.  
  22. This is what's here:
  23.  
  24. 'sman' is a manual type program that allows you to specify very general
  25. rules for looking up documentation on a subject.  It has facilities for
  26. searching Amiga AutoDoc format files for an entry, and for scanning through
  27. dme.refs format files, as used by Matt Dillon's DME editor.  As well, of
  28. course, it can look for documentation based on the name of a file (ie. you
  29. say 'sman fred' and it might look for 'DOCS:fred.doc' depending on how you
  30. set things up.)
  31.  
  32. 'sless' is a text file viewing program with some features that make it work
  33. particularly well with 'sman'.  I think it as at least as good as more.
  34.  
  35.    New to version 1.1
  36.  
  37.     Fixed a serious bug in sman that would sometimes make it totally
  38.     overlook a perfectly good dme.refs or autodoc format match.
  39.  
  40.     Fixed a minor bug in sless that made it start at the wrong line
  41.     number with the -l command line option (only if the file had
  42.     ^L control sequences in it)
  43.  
  44.     There is a new version of sregexp.library that fixes a couple
  45.     of potential GURU causing bugs.
  46.  
  47.  
  48. #!/bin/sh
  49. # This is a shell archive.  Remove anything before this line, then unpack
  50. # it by saving it into a file and typing "sh file".  To overwrite existing
  51. # files, type "sh file -c".  You can also feed this as standard input via
  52. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  53. # will see the following message at the end:
  54. #        "End of archive 1 (of 2)."
  55. # Contents:  ACKNOWLEDGMENTS BUGS_&_REGISTRATION COPYRIGHT.NOTICE
  56. #   OVERVIEW instillation.note sless.doc.uu sman.doc.uu src
  57. #   src/auto_sreg.c src/compilation.notes src/dmakefile src/sless.c
  58. #   src/sless.n src/sless_1.c src/sless_defs.h src/sless_file.c
  59. #   src/sless_help.h src/sless_win.c src/sman.c src/sman.n
  60. #   src/sman_defs.h
  61. # Wrapped by tadguy@ab20 on Mon Jul 29 18:57:29 1991
  62. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  63. if test -f 'ACKNOWLEDGMENTS' -a "${1}" != "-c" ; then 
  64.   echo shar: Will not clobber existing file \"'ACKNOWLEDGMENTS'\"
  65. else
  66. echo shar: Extracting \"'ACKNOWLEDGMENTS'\" \(220 characters\)
  67. sed "s/^X//" >'ACKNOWLEDGMENTS' <<'END_OF_FILE'
  68. X
  69. X    I'd first like to thank Andy Wright for testing version 1.1 (I should
  70. X    have had him test 1.0, oh well.)
  71. X
  72. X    I should also thank Daryl Scora for some useful suggestions, and Matt
  73. X    Dillon for a great compiler.
  74. END_OF_FILE
  75. if test 220 -ne `wc -c <'ACKNOWLEDGMENTS'`; then
  76.     echo shar: \"'ACKNOWLEDGMENTS'\" unpacked with wrong size!
  77. fi
  78. chmod +x 'ACKNOWLEDGMENTS'
  79. # end of 'ACKNOWLEDGMENTS'
  80. fi
  81. if test -f 'BUGS_&_REGISTRATION' -a "${1}" != "-c" ; then 
  82.   echo shar: Will not clobber existing file \"'BUGS_&_REGISTRATION'\"
  83. else
  84. echo shar: Extracting \"'BUGS_&_REGISTRATION'\" \(324 characters\)
  85. sed "s/^X//" >'BUGS_&_REGISTRATION' <<'END_OF_FILE'
  86. X
  87. XSend bug reports, comments, etc. to
  88. X
  89. X    Jon Spencer.
  90. X
  91. X    EMail:    bhgs@gpu.utcs.utoronto.ca
  92. X
  93. X
  94. XRegistration:
  95. X    The registration fee for these programs is $2654.37, and for this you
  96. X    will receive a birthday card for the rest of my, or your, natural life
  97. X    (whichever ends first).  Please include your birth date ;-).
  98. X
  99. END_OF_FILE
  100. if test 324 -ne `wc -c <'BUGS_&_REGISTRATION'`; then
  101.     echo shar: \"'BUGS_&_REGISTRATION'\" unpacked with wrong size!
  102. fi
  103. # end of 'BUGS_&_REGISTRATION'
  104. fi
  105. if test -f 'COPYRIGHT.NOTICE' -a "${1}" != "-c" ; then 
  106.   echo shar: Will not clobber existing file \"'COPYRIGHT.NOTICE'\"
  107. else
  108. echo shar: Extracting \"'COPYRIGHT.NOTICE'\" \(1144 characters\)
  109. sed "s/^X//" >'COPYRIGHT.NOTICE' <<'END_OF_FILE'
  110. X
  111. X    The programs 'sman', 'sless', and the library 'sregexp.library', and
  112. X    all sources and documentation relating to these programs included in
  113. X    this distribution are Copyright (c) 1991, by Jon Spencer.
  114. X
  115. X    Permission is given to redistribute any part or all of this
  116. X    distribution, either modified or unmodified, PROVIDED THAT:
  117. X    - the distribution is on a not-for-profit basis,
  118. X    - this copyright notice is included in the distribution,
  119. X    - and if a modified version is distributed, clear indication
  120. X      that it is modified is included.
  121. X
  122. X    All other rights are reserved by the author, Jon Spencer.
  123. X
  124. X
  125. X(disclaimer borrowed, somewhat modified, from the DICE distribution)
  126. X
  127. X    PROGRAM DISCLAIMER: THE PROGRAMS AND LIBRARY ARE PROVIDED "AS IS"
  128. X    WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  129. X    BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  130. X    FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE RESULTS
  131. X    AND PERFORMANCE OF ANY PROGRAM IS ASSUMED BY YOU.  Should the program
  132. X    prove defective, you assume the entire cost of all necessary servicing,
  133. X    repair, or correction.
  134. X
  135. END_OF_FILE
  136. if test 1144 -ne `wc -c <'COPYRIGHT.NOTICE'`; then
  137.     echo shar: \"'COPYRIGHT.NOTICE'\" unpacked with wrong size!
  138. fi
  139. # end of 'COPYRIGHT.NOTICE'
  140. fi
  141. if test -f 'OVERVIEW' -a "${1}" != "-c" ; then 
  142.   echo shar: Will not clobber existing file \"'OVERVIEW'\"
  143. else
  144. echo shar: Extracting \"'OVERVIEW'\" \(1227 characters\)
  145. sed "s/^X//" >'OVERVIEW' <<'END_OF_FILE'
  146. X
  147. X   The first release (1.0) of these programs was somewhat riddled with
  148. Xbugs.  I think I've gotten most of the bad ones, at least it seems to
  149. Xperform as advertised now.
  150. X
  151. XThis is what's here:
  152. X
  153. X'sman' is a manual type program that allows you to specify very general
  154. Xrules for looking up documentation on a subject.  It has facilities for
  155. Xsearching Amiga AutoDoc format files for an entry, and for scanning through
  156. Xdme.refs format files, as used by Matt Dillon's DME editor.  As well, of
  157. Xcourse, it can look for documentation based on the name of a file (ie. you
  158. Xsay 'sman fred' and it might look for 'DOCS:fred.doc' depending on how you
  159. Xset things up.)
  160. X
  161. X'sless' is a text file viewing program with some features that make it work
  162. Xparticularly well with 'sman'.  I think it as at least as good as more.
  163. X
  164. X   New to version 1.1
  165. X
  166. X    Fixed a serious bug in sman that would sometimes make it totally
  167. X    overlook a perfectly good dme.refs or autodoc format match.
  168. X
  169. X    Fixed a minor bug in sless that made it start at the wrong line
  170. X    number with the -l command line option (only if the file had
  171. X    ^L control sequences in it)
  172. X
  173. X    There is a new version of sregexp.library that fixes a couple
  174. X    of potential GURU causing bugs.
  175. X
  176. END_OF_FILE
  177. if test 1227 -ne `wc -c <'OVERVIEW'`; then
  178.     echo shar: \"'OVERVIEW'\" unpacked with wrong size!
  179. fi
  180. # end of 'OVERVIEW'
  181. fi
  182. if test -f 'instillation.note' -a "${1}" != "-c" ; then 
  183.   echo shar: Will not clobber existing file \"'instillation.note'\"
  184. else
  185. echo shar: Extracting \"'instillation.note'\" \(125 characters\)
  186. sed "s/^X//" >'instillation.note' <<'END_OF_FILE'
  187. X
  188. X
  189. X    For these programs to work, you must copy the file 'sregexp.library'
  190. X    from this directory to your LIBS: directory.
  191. X
  192. END_OF_FILE
  193. if test 125 -ne `wc -c <'instillation.note'`; then
  194.     echo shar: \"'instillation.note'\" unpacked with wrong size!
  195. fi
  196. # end of 'instillation.note'
  197. fi
  198. if test -f 'sless.doc.uu' -a "${1}" != "-c" ; then 
  199.   echo shar: Will not clobber existing file \"'sless.doc.uu'\"
  200. else
  201. echo shar: Extracting \"'sless.doc.uu'\" \(2281 characters\)
  202. sed "s/^X//" >'sless.doc.uu' <<'END_OF_FILE'
  203. Xbegin 600 sless.doc
  204. XM"B`@("`@4TQ%4U,H,2D@("`@("`@("`@("`@($%-24=!(%!R;V=R86UM97(GX
  205. XM<R!-86YU86P@("`@("`@("`@("`@("!33$534R@Q*0H*"@H@("`@()LQ;4Y!M
  206. XM344@"B`@("`@("`@("";,&US;&5S<R`M(&$@9&]C=6UE;G0@=FEE=VEN9R!P4
  207. XM<F]G<F%M+B`@"@H@("`@()LQ;5-93D]04TE3(`H@("`@("`@("`@<VQE<W,@?
  208. XMFS!M6RUL(&QI;F5N;R!\("UC(&-H87)P;W-=(&9I;&4@"@H@("`@()LQ;41%@
  209. XM4T-225!424].(`H@("`@("`@("`@FS!M5&AE<F4@(&%R92`@<&QE;G1Y("!O8
  210. XM9B!G;V]D('1E>'0@=FEE=VEN9R!P<F]G<F%M<R!A<F]U;F0@9F]R"B`@("`@R
  211. XM("`@("!T:&4@06UI9V$L('=E;&PL(&AE<F4G<R!A;F]T:&5R+B`@"@H@("`@]
  212. XM("`@("`@5&AE(&]R:6=I;F%L(')E87-O;B!F;W(@=W)I=&EN9R";-&US;&5S<
  213. XM<YLP;2!W87,@87,@82`@<VEM<&QE("!T97AT"B`@("`@("`@("!V:65W97(@6
  214. XM('1O("!W;W)K('=I=&@@FS1M<VUA;ILP;2P@=VAI8V@@8V]U;&0@<W1A<G0@I
  215. XM=FEE=VEN9R!A(&9I;&4*("`@("`@("`@(&%T(&%N(&%R8FET<F%R>2!L:6YE`
  216. XM(&YU;6)E<B!O<B!C:&%R86-T97(@<&]S:71I;VXN("!)="!T=7)N<PH@("`@=
  217. XM("`@("`@;W5T+"!A('1E>'0@=FEE=V5R(&ES(&$@8V]M<&QI8V%T960@=&AIC
  218. XM;F<L('-O(&ET(&=R97<@=&\@(&)E"B`@("`@("`@("!A(&QO="!B:6=G97(@I
  219. XM=&AA;B";-&US;6%NFS!M(&ET<V5L9B$@($]H(%=E;&PN+BX@(`H*("`@("`@_
  220. XM("`@(%1H9:!U<V%G9:!I<Z!S=')A:6=H=*!F;W)W87)D+J"@5FEE=R`@82`@7
  221. XM9FEL92!A;F0@:&ET(#QH96QP/@H@("`@("`@("`@=&\@9V5T(&$@:&5L<"!S%
  222. XM8W)E96X@;VX@=&AE(&-O;6UA;F1S+B`@"@H@("`@("`@("`@5&AE(&]N;'D@"
  223. XM=&AI;F<@=&AA="!N965D<R`@82`@;&ET=&QE("!C;&%R:69I8V%T:6]N("!I*
  224. XM<R`@=&AE"B`@("`@("`@("!S96%R8V@@86QG;W)I=&AM+B`@("!)9B`@=&AEY
  225. XM('-E87)C:"!P871T97)N('EO=2!E;G1E<B!H87,@;F\*("`@("`@("`@('5NU
  226. XM97-C87!E9"!W:6QD8V%R9"!C:&%R86-T97)S+"!T:&5N(&$@)R,_)R!W:6QLC
  227. XM(&)E('!R97!E;F1E9`H@("`@("`@("`@86YD(&%P<&5N9&5D('1O('1H92`@`
  228. XM<&%T=&5R;BX@("`@268@(&ET("!H87,@(&%N>2`@=6YE<V-A<&5D"B`@("`@>
  229. XM("`@("!W:6QD8V%R9"`@8VAA<F%C=&5R<RP@=&AE;B!T:&4@<&%T=&5R;B!W;
  230. XM:6QL(&AA=F4@=&\@;6%T8V@@86X*("`@("`@("`@(&5N=&ER9:!L:6YE+J"@K
  231. XM4V5E()LT;7-R96=E>'";,&TNFS1M9&]CFS!M(&9O<B!A(&1I<V-U<W-I;VX@S
  232. XM;V8@=&AE("!L96=A;`H@("`@("`@("`@=VEL9&-A<F0@<WEN=&%X+B`@"@H*B
  233. XM("`@("";,6U3144@04Q33R`*("`@("`@("`@()LP;7-M86XH,2D@"@H*("`@V
  234. XM("";,6U"54<@4D503U)44R`*("`@("`@("`@()LP;5!L96%S92!S96YD(&)UC
  235. XM9R!R97!O<G1S+"!C;VUM96YT<R!E=&,N("!T;R`*"B`@("`@("`@("`@("`@I
  236. XM($IO;B!3<&5N8V5R(`H*("`@("`@("`@("`@("`@14UA:6PZ(&)H9W-`9W!U=
  237. XM+G5T8W,N=71O<F]N=&\N8V$@"@H*"@H*"@H*"@H*"@H*"@H*"@H*"B`@("`@S
  238. XM2F]N(%-P96YC97(@("`@("`@("`@("`@("`@("`@("`@+3$M("`@("`@("`@"
  239. X;("`@("`@("`@("`@("!697)S:6]N(#$N,0H*J
  240. X``
  241. Xend
  242. Xsize 1602
  243. END_OF_FILE
  244. if test 2281 -ne `wc -c <'sless.doc.uu'`; then
  245.     echo shar: \"'sless.doc.uu'\" unpacked with wrong size!
  246. fi
  247. # end of 'sless.doc.uu'
  248. fi
  249. if test -f 'sman.doc.uu' -a "${1}" != "-c" ; then 
  250.   echo shar: Will not clobber existing file \"'sman.doc.uu'\"
  251. else
  252. echo shar: Extracting \"'sman.doc.uu'\" \(7127 characters\)
  253. sed "s/^X//" >'sman.doc.uu' <<'END_OF_FILE'
  254. Xbegin 600 sman.doc
  255. XM"B`@("`@4TU!3B@Q*2`@("`@("`@("`@("`@($%-24=!(%!R;V=R86UM97(G]
  256. XM<R!-86YU86P@("`@("`@("`@("`@("`@4TU!3B@Q*0H*"@H@("`@()LQ;4Y!R
  257. XM344@"B`@("`@("`@("";,&US;6%N("T@82!D;V-U;65N="!L;V]K=7`@<')O;
  258. XM9W)A;2X@(`H*("`@("";,6U364Y/4%-)4R`*("`@("`@("`@('-M86X@FS!M[
  259. XM6RUP(%-E87)C:"!0871T97)N72!;+78@5FEE=V5R72!T87)G970@6W1A<F=E+
  260. XM="XN+ET@"@H@("`@()LQ;41%4T-225!424].(`H@("`@("`@("`@FS!M5&AEO
  261. XM<F4@(&ES("!N;R!U;FEF;W)M('-T86YD87)D(&9O<B!T:&4@9F]R;6%T(&]R3
  262. XM('!O<VET:6]N(&]F"B`@("`@("`@("!D;V-U;65N=&%T:6]N(&9I;&5S("!OP
  263. XM;B`@=&AE("!!;6EG82X@(%1H:7,@(&UA:V5S("!A("!M86YU86P*("`@("`@.
  264. XM("`@('!R;V=R86T@(&EN("!T:&4@('-T>6QE("!O9B`@=&AE(%5N:7@@FS1MW
  265. XM;6%NFS!M('!R;V=R86T@82!S;VUE=VAA=`H@("`@("`@("`@9&EF9FEC=6QT9
  266. XM('1H:6YG('1O(&-R96%T92X@()LT;7-M86Z;,&T@871T96UP=',@=&\@(&]V<
  267. XM97)C;VUE("!T:&ES"B`@("`@("`@("!D:69F:6-U;'1Y("!B>2`@86QL;W=I3
  268. XM;F<@('1H92`@=7-E<B!T;R!S<&5C:69Y('%U:71E(&=E;F5R86P*("`@("`@[
  269. XM("`@(')U;&5S(&9O<B!T:&4@;&]C871I;VX@(&]F("!D;V-U;65N=&%T:6]N[
  270. XM("!F:6QE<RX@("`@3VYC92`@80H@("`@("`@("`@9&]C=6UE;G0@(&ES(&QOG
  271. XM8V%T960L(&ET(&ES('!A<W-E9"!O;B!T;R!A('1E>'0@=FEE=V5R('1O(&)E(
  272. XM"B`@("`@("`@("!D:7-P;&%Y960N("`*"B`@("`@("`@("!4:&5R92!A<F4@[
  273. XM='=O('=A>7,@=&AE(&1O8W5M96YT871I;VX@(&QO;VMU<"`@<G5L97,@(&-A"
  274. XM;B`@8F4*("`@("`@("`@('!A<W-E9"!T;R`@FS1M<VUA;ILP;2X@("!4:&4@T
  275. XM9FER<W0@:7,@8GD@=&AE('5S92!O9B!T:&4@+9LQ;7`@FS!M8V]M;6%N9`H@:
  276. XM("`@("`@("`@;&EN92`@87)G=6UE;G0L("!T:&4@('-E8V]N9"`@:7,@(&)Y+
  277. XM("!T:&4@($5.5CH@(&5N=FER;VYM96YT"B`@("`@("`@("!V87)I86)L92";D
  278. XM,6U3;6%N4&%T:)LP;2X@("!4:&4@8V]M;6%N9"!L:6YE(&%R9W5M96YT('=IK
  279. XM;&P@;W9E<G)I9&4*("`@("`@("`@(&%N>2!D969I;FET:6]N(&]F('1H92!E.
  280. XM;G9I<F]N;65N="!V87)I86)L92P@8G5T(&%T(&QE87-T(&]N90H@("`@("`@'
  281. XM("`@;75S="!B92!D969I;F5D+B`@"@H@("`@("`@("`@5&AE(&9O<FUA="!O:
  282. XM9B!T:&4@;&]O:W5P(')U;&4@:7,Z(`H*("`@("`@("`@("`@("`@<G5L93$['
  283. XM<G5L93([+BXN("`*"B`@("`@("`@("!%86-H(&]F('1H92!R=6QE<R!W:6QLM
  284. XM(&)E('-E87)C:&5D(&EN(&]R9&5R('5N=&EL(&$@;6%T8V@@:7,*("`@("`@Y
  285. XM("`@(&9O=6YD+B`@02!R=6QE(&ES(&9O<FUE9"!B>2!A;B!O<'1I;VYA;"`@L
  286. XM<W!E8VEA;"`@8VAA<F%C=&5R+`H@("`@("`@("`@=VAI8V@@('-P96-I9FEE?
  287. XM<R`@=&AE("!K:6YD(&]F('-E87)C:"!T;R!B92!P97)F;W)M960@;VX@=&AE1
  288. XM"B`@("`@("`@("!M871C:&EN9R!F:6QE<RP@9F]L;&]W960@8GD@82`H<&]S&
  289. XM<VEB;'DI('=I;&1C87)D960@06UI9V%$3U,*("`@("`@("`@('!A=&@@<W!E#
  290. XM8VEF>6EN9R!T:&4@9FEL97,@=&\@8F4@<V5A<F-H960N("`@4V5E("";-&US@
  291. XM<F5G97APFS!M+ILT;61O8YLP;0H@("`@("`@("`@9F]R(&$@9&ES8W5S<VEOC
  292. XM;B!O9B!T:&4@=VEL9&-A<F0@9F]R;6%T+B`@"@H@("`@("`@("`@5&AE<F4@Q
  293. XM87)E(&-U<G)E;G1L>2!T:')E92!K:6YD<R!O9B!S96%R8V@@<G5L97,@:6UPM
  294. XM;&5M96YT960Z(`H*("`@("`@("`@("";,6U$969A=6QTH)LP;2`@268@('1H]
  295. XM92`@<G5L92`@9&]E<R`@;F]T("!S=&%R="`@=VET:"`@;VYE(&]F('1H90H@%
  296. XM("`@("`@("`@("`@(&-H87)A8W1E<G,@9&ES8W5S<V5D(&)E;&]W+"!T:&5N;
  297. XM(&YO("!S<&5C:6%L("!S96%R8V@@(&ES"B`@("`@("`@("`@("`@9&]N92`@@
  298. XM;VX@=&AE(&9I;&5S(&]N('1H92!P871H+"!A;F0@FS1M<VUA;ILP;2!W:6QLV
  299. XM('-U8V-E960@;VX*("`@("`@("`@("`@("!T:&4@9FER<W0@9FEL92!F;W5ND
  300. XM9"X@("`@5&AE<F4@(&ES("!A("!S<&5C:6%L("!W:6QD8V%R9`H@("`@("`@<
  301. XM("`@("`@(&-H87)A8W1E<B!D969I;F5D("!I;B`@<VUA;B!T;R!M86ME('1H_
  302. XM:7,@=7-E9G5L+B`@268@=&AE"B`@("`@("`@("`@("`@8VAA<F%C=&5R("<FR
  303. XM)R!I<R!F;W5N9"!I;B!T:&4@<V5A<F-H('!A=&@L("!I="`@=VEL;"`@8F4*L
  304. XM("`@("`@("`@("`@("!E>'!A;F1E9"!T;R`@=&AE("!C=7)R96YT("!T87)G^
  305. XM970N("`@1F]R(&5X86UP;&4L(&EF('EO=0H@("`@("`@("`@("`@('1Y<&5DB
  306. XM("`G<VUA;B`@=&5S="<@(&%N9"`@()LQ;5-M86Y0871H("`@FS!M=V%S("`@H
  307. XM9&5F:6YE9"`@(&%S"B`@("`@("`@("`@("`@)T1/0U,Z+BXN+R8N*&1O8WQMK
  308. XM86XI)RP@('1H96X@=&AE('!A=&@@<VUA;B!W;W5L9"!T<GD@=&\*("`@("`@.
  309. XM("`@("`@("!M871C:"!W;W5L9"!B92`G1$]#4SHN+BXO*'1E<W0I+BAD;V-\[
  310. XM;6%N*2<N("`*"B`@("`@("`@("`@0*"@268@=&AI<R!I<R!T:&4@9FER<W0@Z
  311. XM8VAA<F%C=&5R(&]F('1H92`@<G5L92P@('1H96X@('-M86X*("`@("`@("`@O
  312. XM("`@("!W:6QL(&%S<W5M92!T:&4@;6%T8VAE9"!F:6QE<R!A<F4@FS1M9&UEZ
  313. XMFS!M+ILT;7)E9G.;,&T@9F]R;6%T(&9I;&5S+`H@("`@("`@("`@("`@(&%SP
  314. XM('5S960@(&)Y($UA='0@1&EL;&]N)W,@FS1M9&UEFS!M(&5D:71O<BX@(%1H9
  315. XM92!F:6QE<R!W:6QL(&)E"B`@("`@("`@("`@("`@<V5A<F-H960@9F]R(&%NV
  316. XM(&5N=')Y(&UA=&-H:6YG('1H92!T87)G970N("`*"@H*"@H*"@H@("`@($IOF
  317. XM;B!3<&5N8V5R("`@("`@("`@("`@("`@("`@("`@("TQ+2`@("`@("`@("`@)
  318. XM("`@("`@("`@("`@5F5R<VEO;B`Q+C$*"@H@("`@(%--04XH,2D@("`@("`@E
  319. XM("`@("`@("!!34E'02!0<F]G<F%M;65R)W,@36%N=6%L("`@("`@("`@("`@S
  320. XM("`@(%--04XH,2D*"@H@("`@("`@("`@("N@H%1H:7,@='EP92!O9B!R=6QEA
  321. XM('1E;&QS("";-&US;6%NFS!M("!T:&4@(&UA=&-H:6YG("!F:6QE<R`@87)E^
  322. XM"B`@("`@("`@("`@("`@06UI9V$@075T;V1O8R`@9F]R;6%T(&9I;&5S+B`@"
  323. XM16%C:"!F:6QE(&]N('1H92!P871H('=I;&P*("`@("`@("`@("`@("!B92!S8
  324. XM96%R8V@@(&9O<B`@86X@(&5N=')Y("!M871C:&EN9R`@=&AE("!T87)G970N,
  325. XM("`@($9O<@H@("`@("`@("`@("`@(&5X86UP;&4L("!I9B`@FS%M4VUA;E!A1
  326. XM=&@@()LP;7=A<R`@)RM!=71O9&]C<SHC/R\C/RYD;V,G+"!T:&5N"B`@("`@0
  327. XM("`@("`@("`@)W-M86X@5W)I=&4G('=O=6QD(&UA=&-H('1O(`H@("`@("`@-
  328. XM("`@("`@("`@("=!=71O9&]C<SI,:6)R87)I97-!+4LO9&]S+F1O8R<@*'5ND
  329. XM9&5R(#$N,R!A;GEW87DI+B`@"@H@("`@("`@("`@06QL(&9I;&4@;F%M92!S^
  330. XM96%R8VAE<R!A<F4@8V%S92!I;G-E;G-I=&EV92X@("!!;&P@('-E87)C:&5SU
  331. XM"B`@("`@("`@("!W:71H:6X@(&$@(&9I;&4@("AF;W(@("<K)R`@86YD("`G@
  332. XM0"<@('1Y<&4@(')U;&5S*2`@87)E(&-A<V4*("`@("`@("`@('-E;G-I=&EVP
  333. XM92X@(`H*("`@("`@("`@($]N8V4@FS1M<VUA;ILP;2!H87,@9F]U;F0@82!M5
  334. XM871C:"P@=&AA="!F:6QE(&ES('!A<W-E9"!O;G1O(&$@=&5X=`H@("`@("`@I
  335. XM("`@=FEE=V5R(&9O<B!D:7-P;&%Y+B`@5&AE(&1E9F%U;'0@=FEE=V5R(&ESQ
  336. XM()LT;7-L97-SFS!M+"`@8G5T("!T:&ES"B`@("`@("`@("!C86X@(&)E(&]VU
  337. XM97)R:61D96X@8GD@96ET:&5R('1H92`MFS%M=B";,&UC;VUM86YD(&QI;F4@E
  338. XM87)G=6UE;G0@;W(*("`@("`@("`@('1H92!E;G9I<F]N;65N="!V87)I86)L%
  339. XM92";,6U3;6%N5FEE=V5RFS!M+B`@268@=&AE(&1E9F%U;'0@('9I97=E<@H@V
  340. XM("`@("`@("`@:7,@(&YO="!O=F5R<FED9&5N+"!T:&5N(&)O=&@@)RLG(&%NO
  341. XM9"`G0"<@<W1Y;&4@;6%T8VAE<R!W:6QL"B`@("`@("`@("!T96QL()LT;7-LV
  342. XM97-SFS!M('1O('-T87)T("!D:7-P;&%Y:6YG("!T:&4@(&9I;&4@(&%T("!TR
  343. XM:&4@(&-O<G)E8W0*("`@("`@("`@('!O<VET:6]N+B`@($EF("!T:&4@(&1E%
  344. XM9F%U;'0@('9I97=E<B!I<R!O=F5R<FED9&5N+"!T:&5N(&%L;`H@("`@("`@Z
  345. XM("`@9FEL97,@=VEL;"!B92!D:7-P;&%Y960@870@=&AE(&9I<G-T(&QI;F4NE
  346. XM("`*"@H*("`@("";,6U%6$%-4$Q%4R`*"B`@("`@("`@("";,&U%>&%M<&QE8
  347. XM()LQ;5-M86Y0871H()LP;79A<FEA8FQE.B`*"B`@("`@("`@("`@("`@*T%UB
  348. XM=&]$;V-S.B,_+R,_+F1O8SM`9&-C.F1O8R]D;64N<F5F<SM`9&-C.FUA;B\@_
  349. XM;64N<F5F<SL@"B`@("`@("`@("`@("`@1$]#4SHN+BXO)B@N9&]C?"YM86Y\%
  350. XM+G1X="D@"@H*("`@("";,6U!1$1)5$E/3B!#3TY3241%4D%424].4R`*"B`@3
  351. XM("`@("`@("";,&V;-&US;6%NFS!M('=I;&P@86QW87ES('1A:V4@=&AE(&9IY
  352. XM<G-T(&UA=&-H('1H870@:70@9FEN9',L('-O("!T:&4*("`@("`@("`@(&]RB
  353. XM9&5R("!O9B`@=&AE("!R=6QE<R!C86X@8F4@=7-E9"!T;R!M86YI<'5L871E9
  354. XM('1H92!O<F1E<B!O9@H@("`@("`@("`@=&AE('-E87)C:"X@(`H*("`@("`@U
  355. XM("`@($%L<V\L("=`)R";-&UD;66;,&TNFS1M<F5F<YLP;2!S='EL92!S96%RA
  356. XM8VAE<R!A<F4@=&AE(&9A<W1E<W0N("`@268@('EO=0H@("`@("`@("`@:&%V9
  357. XM92`@=&AE("";-&UA=71O<F5F<YLP;2!P<F]G<F%M(&9R;VT@36%T="!$:6QL*
  358. XM;VXG<R";-&U$24-%FS!M('!A8VMA9V4L"B`@("`@("`@("!Y;W4@87)E(&)E>
  359. XM='1E<B!O9F8@<G5N;FEN9R!T:&ES("!O;B`@>6]U<B`@075T;V1O8W,L("!R?
  360. XM871H97(*("`@("`@("`@('1H86X@=7-I;F<@=&AE("<K)R!S='EL92!S96%RE
  361. XM8V@N("`*"@H@("`@()LQ;5-%12!!3%-/(`H@("`@("`@("`@FS!M<VQE<W,H0
  362. XM,2D@"@H*("`@("";,6U"54<@4D503U)44R`*("`@("`@("`@()LP;5!L96%SU
  363. XM92!S96YD(&)U9R!R97!O<G1S+"!C;VUM96YT<R!E=&,N("!T;R`*"B`@("`@O
  364. XM("`@("`@("`@($IO;B!3<&5N8V5R(`H*("`@("`@("`@("`@("`@14UA:6PZM
  365. XM(&)H9W-`9W!U+G5T8W,N=71O<F]N=&\N8V$@"@H*"@H*"@H*("`@("!*;VX@(
  366. XM4W!E;F-E<B`@("`@("`@("`@("`@("`@("`@("`M,BT@("`@("`@("`@("`@\
  367. X7("`@("`@("`@(%9E<G-I;VX@,2XQ"@H@*
  368. X``
  369. Xend
  370. Xsize 5063
  371. END_OF_FILE
  372. if test 7127 -ne `wc -c <'sman.doc.uu'`; then
  373.     echo shar: \"'sman.doc.uu'\" unpacked with wrong size!
  374. fi
  375. # end of 'sman.doc.uu'
  376. fi
  377. if test ! -d 'src' ; then
  378.     echo shar: Creating directory \"'src'\"
  379.     mkdir 'src'
  380. fi
  381. if test -f 'src/auto_sreg.c' -a "${1}" != "-c" ; then 
  382.   echo shar: Will not clobber existing file \"'src/auto_sreg.c'\"
  383. else
  384. echo shar: Extracting \"'src/auto_sreg.c'\" \(419 characters\)
  385. sed "s/^X//" >'src/auto_sreg.c' <<'END_OF_FILE'
  386. X
  387. X#include <clib/exec_protos.h>
  388. X#include <clib/dos_protos.h>
  389. X#include <libraries/sregexpbase.h>
  390. X#include <stdlib.h>
  391. X
  392. Xstruct SregExpBase *SregExpBase;
  393. X
  394. X__autoinit void
  395. Xopensreg()
  396. X{
  397. X    if (!(SregExpBase = OpenLibrary("sregexp.library",7))) {
  398. X    Write(Output(),"Couldn't Open 'sregexp.library'.\n",23);
  399. X    _exit(10);
  400. X    }
  401. X}
  402. X
  403. X__autoexit void
  404. Xclosesreg()
  405. X{
  406. X    if (SregExpBase)
  407. X    CloseLibrary((struct Library *)SregExpBase);
  408. X}
  409. X
  410. END_OF_FILE
  411. if test 419 -ne `wc -c <'src/auto_sreg.c'`; then
  412.     echo shar: \"'src/auto_sreg.c'\" unpacked with wrong size!
  413. fi
  414. # end of 'src/auto_sreg.c'
  415. fi
  416. if test -f 'src/compilation.notes' -a "${1}" != "-c" ; then 
  417.   echo shar: Will not clobber existing file \"'src/compilation.notes'\"
  418. else
  419. echo shar: Extracting \"'src/compilation.notes'\" \(1034 characters\)
  420. sed "s/^X//" >'src/compilation.notes' <<'END_OF_FILE'
  421. X
  422. X    First off, if you look in the dmakefile you will see reference
  423. X    to a file noio_main.c.  This file is just the _main routine
  424. X    that comes with the registered version of DICE with the stuff
  425. X    to setup the stdio files removed, and it has exit() call _exit()
  426. X    directly.  I have no license to go around releasing the the
  427. X    source to Dillon's libraries, so I won't.  But you can easily
  428. X    create the file yourself, or just remove all references to it
  429. X    from the dmake file, and all that will happen is you will have
  430. X    a slightly larger program.
  431. X
  432. X    Besides that,  I made everything under 1.3,  but I have done
  433. X    a couple of things that may make this difficult for you.  First
  434. X    off, I have created a clib directory that has the prototypes
  435. X    to all of the library calls in it.    This also allowed my to
  436. X    created a registered args version of the 1.3 Amiga.lib linker
  437. X    library.  The easiest thing to do would just be to make
  438. X    a stack argument version, other than that, I leave it up
  439. X    to your ingenuity.
  440. X
  441. END_OF_FILE
  442. if test 1034 -ne `wc -c <'src/compilation.notes'`; then
  443.     echo shar: \"'src/compilation.notes'\" unpacked with wrong size!
  444. fi
  445. # end of 'src/compilation.notes'
  446. fi
  447. if test -f 'src/dmakefile' -a "${1}" != "-c" ; then 
  448.   echo shar: Will not clobber existing file \"'src/dmakefile'\"
  449. else
  450. echo shar: Extracting \"'src/dmakefile'\" \(1096 characters\)
  451. sed "s/^X//" >'src/dmakefile' <<'END_OF_FILE'
  452. X
  453. X# For no registered args
  454. X#REGARG =
  455. X
  456. X# For registered args.
  457. XREGARG = -mRR
  458. X
  459. X# For a lot of junk
  460. X#DEBUG = -D __DEBUG -D __TRACE__
  461. X
  462. X# For a bit of junk
  463. X#DEBUG = -D __DEBUG__
  464. X
  465. X# for no junk.
  466. XDEBUG =
  467. X
  468. XCC = dcc
  469. XCCOPTS = -I$(OD) $(DEBUG) $(REGARG) -ms -proto -c
  470. XLINKOPTS = -r $(REGARG) -l sregexpsr.lib
  471. X
  472. X# A convinient place for the object files.
  473. XOD = OBJS:sman/
  474. X
  475. X
  476. X
  477. XSLESS_SRC = sless.c sless_1.c sless_win.c sless_file.c \
  478. X        auto_sreg.c noio_main.c
  479. X
  480. XSMAN_SRC = sman.c
  481. X
  482. XSLESS_OBJS = $(SLESS_SRC:"*.c":"$(OD)*.o")
  483. XSMAN_OBJS =  $(SMAN_SRC:"*.c":"$(OD)*.o")
  484. X
  485. X
  486. X
  487. X
  488. Xall: /sless /sman
  489. X
  490. X/sless: $(OD)sless_proto.h $(SLESS_OBJS)
  491. X    -Delete >NIL: %(left)
  492. X    $(CC) $(LINKOPTS) -o%(left) $(SLESS_OBJS)
  493. X
  494. X/sman: $(SMAN_OBJS) $(OD)auto_sreg.o
  495. X    -Delete >NIL: %(left)
  496. X    $(CC) $(LINKOPTS) -o%(left) $(SMAN_OBJS) $(OD)auto_sreg.o
  497. X
  498. X
  499. X
  500. X$(SMAN_OBJS) : $(SMAN_SRC)
  501. X    -Delete >NIL: %(left)
  502. X    $(CC) $(CCOPTS) -o%(left) %(right)
  503. X
  504. X$(SLESS_OBJS) : $(SLESS_SRC)
  505. X    -Delete >NIL: %(left)
  506. X    $(CC) $(CCOPTS) -o%(left) %(right)
  507. X
  508. X$(OD)sless_proto.h : $(SLESS_SRC)
  509. X    -Delete >NIL: %(left)
  510. X    makeproto -o%(left) %(right)
  511. END_OF_FILE
  512. if test 1096 -ne `wc -c <'src/dmakefile'`; then
  513.     echo shar: \"'src/dmakefile'\" unpacked with wrong size!
  514. fi
  515. # end of 'src/dmakefile'
  516. fi
  517. if test -f 'src/sless.c' -a "${1}" != "-c" ; then 
  518.   echo shar: Will not clobber existing file \"'src/sless.c'\"
  519. else
  520. echo shar: Extracting \"'src/sless.c'\" \(6293 characters\)
  521. sed "s/^X//" >'src/sless.c' <<'END_OF_FILE'
  522. X
  523. X#include "sless_defs.h"
  524. X#include <libraries/sregexpbase.h>
  525. X#include <string.h>
  526. X#include <stdlib.h>
  527. X#include <ctype.h>
  528. X#include <clib/dos_protos.h>
  529. X
  530. XPrototype void            usage(void);
  531. XPrototype void            refreshscreen(void);
  532. XPrototype void            waitcommand(void);
  533. XPrototype void            leave(int, char *);
  534. XPrototype int            putline(void);
  535. X
  536. Xconst char memory[] = "sless: Unable to allocate memory.\n";
  537. Xconst char end[]    = " \x9b7m-- END OF FILE --\x9b0m";
  538. Xconst char top[]    = " \x9b7m-- TOP OF FILE --\x9b0m";
  539. Xconst char nopat[]  = " \x9b7m-- Pattern not found --\x9b0m";
  540. Xconst char nolast[] = " \x9b7m-- No previous pattern --\x9b0m";
  541. Xconst char wait[]   = " \x9b7m-- Searching --\x9b0m";
  542. Xconst char abort[]  = " \x9b7m-- Search aborted --\x9b0m";
  543. X
  544. Xchar seek = 0;
  545. Xlong startpos = 0,nextpos = 0;
  546. XFILE *file = NULL,*ofile = NULL;
  547. XBPTR con = 0;
  548. Xint sx,sy;
  549. Xstruct SregExp *lastspat = NULL;
  550. X
  551. Xint main(ac,av)
  552. Xint ac;
  553. Xchar **av;
  554. X{
  555. X    int line = 0,i;
  556. X    char *p,*oldwin = NULL;
  557. X
  558. X    show_line;
  559. X    while (ac > 0) {
  560. X    ac--;
  561. X    av++;
  562. X    if (**av != '-')
  563. X        break;
  564. X    switch (*(*av+1)) {
  565. X        case ('l') :
  566. X        if (line != 0)
  567. X            usage();
  568. X        p = *av+2;
  569. X        while (isdigit(*p))
  570. X            line = line*10 + *p++ - '0';
  571. X        break;
  572. X        case ('c') :
  573. X        if (line != 0)
  574. X            usage();
  575. X        p = *av+2;
  576. X        while (isdigit(*p))
  577. X            line = line*10 - *p++ + '0';
  578. X        break;
  579. X        default :
  580. X        usage();
  581. X    }
  582. X    }
  583. X
  584. X    if (ac < 1)
  585. X    usage();
  586. X    if (!(file = sopen(*av)))
  587. X    leave(15,"Unable to open input stream.\n");
  588. X
  589. X    /* try and find the length of a file.  If it fails or is zero, then
  590. X       we assume we cannot seek into the file.    This catches trying to
  591. X       seek into pipes. */
  592. X    sseek(file,0,SEEK_END);
  593. X    if (stell(file) <= 0)
  594. X    seek = 0;
  595. X    else {
  596. X    seek = 1;
  597. X    sseek(file,0,SEEK_SET);
  598. X    }
  599. X
  600. X    con = makeoutput(*av);
  601. X
  602. X    if (line < 0) {
  603. X    startpos = -line;
  604. X    if (seek)
  605. X        sseek(file,startpos,SEEK_SET);
  606. X    else
  607. X        for (i = 0; i > line; i--)
  608. X        getc(file);
  609. X    } else {
  610. X    for (i = 0; i < line && (p = sgetline(file)); i++) {
  611. X        if (p[strlen(p)-1] == 12)
  612. X        i--;
  613. X        show_line;
  614. X        free(p);
  615. X        show_line;
  616. X        if (seek)
  617. X        startpos = stell(file);
  618. X    }
  619. X    }
  620. X
  621. X    findsize(&sx,&sy,con);
  622. X    refreshscreen();
  623. X    waitcommand();
  624. X
  625. X    closeoutput(con);
  626. X    con = 0;
  627. X    sclose(file);
  628. X    file = NULL;
  629. X    return 0;
  630. X}
  631. X
  632. Xvoid
  633. Xusage()
  634. X{
  635. X    show_line;
  636. X    sputs("sless V"\
  637. X      VERSION\
  638. X      ", "\
  639. X      __DATE__\
  640. X      ", \xA9Copyright 1991 by Jon Spencer.\n");
  641. X    sputs("Usage: sless [-llineno | -ccharpos] file\n");
  642. X    sputs("Where lineno is the optional starting line number,\n");
  643. X    sputs("or charpos is the optional starting character positon.\n");
  644. X    exit(2);
  645. X}
  646. X
  647. Xvoid
  648. Xleave(x,p)
  649. Xint x;
  650. Xchar *p;
  651. X{
  652. X    show_line;
  653. X    sputs(p);
  654. X    closeoutput(con);
  655. X    if (con)
  656. X    closeoutput(con);
  657. X    if (file)
  658. X    sclose(file);
  659. X    if (ofile)
  660. X    sclose(ofile);
  661. X    exit(x);
  662. X}
  663. X
  664. Xvoid
  665. Xwaitcommand()
  666. X{
  667. X    short c;
  668. X
  669. X    show_line;
  670. X    do {
  671. X    switch (c = getconchar(con)) {
  672. X        case (' ') :
  673. X        sgetcur(file);
  674. X        if (seof(file) && nextpos > 0)
  675. X            nextpos = -1;
  676. X        if (nextpos >= 0) {
  677. X            startpos = nextpos;
  678. X            refreshscreen();
  679. X        } else {
  680. X            bottomline();
  681. X            if (nextpos-- == -2)
  682. X            return;
  683. X            putconstr(end,con);
  684. X        }
  685. X        break;
  686. X        case ('<') :
  687. X        case (makeconid('T',0)) :
  688. X        if (seek) {
  689. X            if (startpos == 0) {
  690. X            bottomline();
  691. X            putconstr(top,con);
  692. X            } else {
  693. X            startpos = 0;
  694. X            refreshscreen();
  695. X            }
  696. X        }
  697. X        break;
  698. X        case (13) :
  699. X        case (makeconid('B',0)) :
  700. X        sgetcur(file);
  701. X        if (seof(file) && nextpos > 0)
  702. X            nextpos = -1;
  703. X        if (nextpos >= 0) {
  704. X            downone();
  705. X        } else {
  706. X            bottomline();
  707. X            if (nextpos-- == -2)
  708. X            return;
  709. X            putconstr(end,con);
  710. X        }
  711. X        break;
  712. X        case ('q') :
  713. X        bottomline();
  714. X        return;
  715. X        case (8) :
  716. X        case ('b') :
  717. X        if (seek) {
  718. X            if (startpos == 0) {
  719. X            bottomline();
  720. X            putconstr(top,con);
  721. X            } else
  722. X            backup(sy-2);
  723. X        }
  724. X        break;
  725. X        case ('d') :
  726. X        sgetcur(file);
  727. X        if (seof(file) && nextpos > 0)
  728. X            nextpos = -1;
  729. X        if (nextpos >= 0) {
  730. X            int i = 1;
  731. X
  732. X            while (i++ < sy/2 && nextpos > 0)
  733. X            startpos = skiponeline(startpos);
  734. X            refreshscreen();
  735. X        } else {
  736. X            bottomline();
  737. X            if (nextpos-- == -2)
  738. X            return;
  739. X            putconstr(end,con);
  740. X        }
  741. X        break;
  742. X        case ('>') :
  743. X        case (makeconid('S',0)) :
  744. X        if (seek) {
  745. X            sseek(file,-1,SEEK_END);
  746. X            startpos = stell(file);
  747. X            backup(sy-1);
  748. X        }
  749. X        break;
  750. X        case ('u') :
  751. X        if (seek) {
  752. X            if (startpos != 0) {
  753. X            backup(sy/2-1);
  754. X            } else {
  755. X            bottomline();
  756. X            putconstr(top,con);
  757. X            }
  758. X        }
  759. X        break;
  760. X        case (makeconid('A',0)) :
  761. X        if (seek) {
  762. X            if (startpos != 0) {
  763. X            uponeline();
  764. X            } else {
  765. X            bottomline();
  766. X            putconstr(top,con);
  767. X            }
  768. X        }
  769. X        break;
  770. X        case ('/') :
  771. X        if (seek) {
  772. X            bottomline();
  773. X            putconstr("/",con);
  774. X            if (!searchfor())
  775. X            break;
  776. X            nextpat();
  777. X        }
  778. X        break;
  779. X        case ('n') :
  780. X        if (seek)
  781. X            nextpat();
  782. X        break;
  783. X        case ('p') :
  784. X        if (seek)
  785. X            prevpat();
  786. X        break;
  787. X        case (';') :
  788. X        if (seek) {
  789. X            bottomline();
  790. X            putconstr(";",con);
  791. X            if (!searchfor())
  792. X            break;
  793. X            prevpat();
  794. X        }
  795. X        break;
  796. X        case (makeconid('?','~')) :
  797. X        case ('h') :
  798. X        case ('?') :
  799. X        if (!ofile)
  800. X            behelpfull();
  801. X        break;
  802. X    }
  803. X    } while (TRUE);
  804. X}
  805. X
  806. Xvoid
  807. Xrefreshscreen()
  808. X{
  809. X    int y,c;
  810. X    long t;
  811. X
  812. X    show_line;
  813. X    putconstr("\x9b0 p\x0c",con);
  814. X
  815. X    y = sy;
  816. X    if (seek)
  817. X    sseek(file,startpos,SEEK_SET);
  818. X    do {
  819. X    if (seek && y > 1)
  820. X        nextpos = stell(file);
  821. X    } while (--y > 0 && !(c = putline()));
  822. X
  823. X    if (seof(file))
  824. X    nextpos = -1;
  825. X    if (c == 2) {
  826. X    nextpos = stell(file);
  827. X    }
  828. X
  829. X    while (--y > 0)
  830. X    putconchar(10,con);
  831. X
  832. X    putconstr(": \x9b p",con);
  833. X}
  834. X
  835. Xint
  836. Xputline()
  837. X{
  838. X    char *p,*q;
  839. X
  840. X    show_line;
  841. X
  842. X    if (!(p = sgetline(file))) {
  843. X    putconchar(10,con);
  844. X    return TRUE;
  845. X    }
  846. X    q = skipdispline(p);
  847. X    if (*(q-1) == 12) {
  848. X    *(q-1) = 0;
  849. X    putconstr(p,con);
  850. X    putconstr("^L\n",con);
  851. X    free(p);
  852. X    return 2;
  853. X    } else if (*q) {
  854. X    sseek(file,q - p - strlen(p),SEEK_CUR);
  855. X    *q++ = '\n';
  856. X    *q = 0;
  857. X    }
  858. X    putconstr(p,con);
  859. X    free(p);
  860. X    return seof(file);
  861. X}
  862. X
  863. X/*
  864. X#include <stdarg.h>
  865. X
  866. XPrototype int printf(const char *, ...);
  867. Xextern int    vsprintf(char *, const char *, va_list);
  868. X
  869. Xint printf(f, ...)
  870. Xconst char *f;
  871. X{
  872. X    char buff[100];
  873. X    va_list va;
  874. X
  875. X    va_start(va,f);
  876. X    vsprintf(buff,f,va);
  877. X    va_end(va);
  878. X    Write(Output(),buff,strlen(buff));
  879. X}
  880. X*/
  881. END_OF_FILE
  882. if test 6293 -ne `wc -c <'src/sless.c'`; then
  883.     echo shar: \"'src/sless.c'\" unpacked with wrong size!
  884. fi
  885. # end of 'src/sless.c'
  886. fi
  887. if test -f 'src/sless.n' -a "${1}" != "-c" ; then 
  888.   echo shar: Will not clobber existing file \"'src/sless.n'\"
  889. else
  890. echo shar: Extracting \"'src/sless.n'\" \(1193 characters\)
  891. sed "s/^X//" >'src/sless.n' <<'END_OF_FILE'
  892. X.*
  893. X.*
  894. X.TH SLESS 1 "AMIGA Programmer's Manual" "Jon Spencer" "Version 1.1"
  895. X.SH NAME
  896. Xsless - a document viewing program.
  897. X.SH SYNOPSIS
  898. X.bo "sless
  899. X[-l lineno | -c charpos] file
  900. X.SH DESCRIPTION
  901. XThere are plenty of good text viewing programs around for the Amiga,
  902. Xwell, here's another.
  903. X
  904. XThe original reason for writing
  905. X.ul "sless
  906. Xwas as a simple text viewer
  907. Xto work with
  908. X.ul "sman,
  909. Xwhich could start viewing a file at an arbitrary line number or
  910. Xcharacter position.  It turns out, a text viewer is a complicated
  911. Xthing, so it grew to be a lot bigger than
  912. X.ul "sman
  913. Xitself!  Oh Well...
  914. X
  915. XThe usage is straight forward.    View a file and hit <help> to
  916. Xget a help screen on the commands.
  917. X
  918. XThe only thing that needs a little clarification is the search
  919. Xalgorithm.  If the search pattern you enter has no unescaped
  920. Xwildcard characters, then a '#?' will be prepended and appended to
  921. Xthe pattern.  If it has any unescaped wildcard characters, then
  922. Xthe pattern will have to match an entire line.    See
  923. X.ul "sregexp.doc
  924. Xfor a discussion of the legal wildcard syntax.
  925. X
  926. X.SH "SEE ALSO"
  927. Xsman(1)
  928. X
  929. X.SH "BUG REPORTS"
  930. XPlease send bug reports, comments etc. to
  931. X.in +5
  932. X
  933. XJon Spencer
  934. X
  935. XEMail: bhgs@@gpu.utcs.utoronto.ca
  936. X.in-5
  937. X
  938. END_OF_FILE
  939. if test 1193 -ne `wc -c <'src/sless.n'`; then
  940.     echo shar: \"'src/sless.n'\" unpacked with wrong size!
  941. fi
  942. # end of 'src/sless.n'
  943. fi
  944. if test -f 'src/sless_1.c' -a "${1}" != "-c" ; then 
  945.   echo shar: Will not clobber existing file \"'src/sless_1.c'\"
  946. else
  947. echo shar: Extracting \"'src/sless_1.c'\" \(6670 characters\)
  948. sed "s/^X//" >'src/sless_1.c' <<'END_OF_FILE'
  949. X
  950. X#include "sless_defs.h"
  951. X#include <libraries/sregexpbase.h>
  952. X#include <string.h>
  953. X#include <stdlib.h>
  954. X#include <ctype.h>
  955. X#include <exec/execbase.h>
  956. X#include <clib/dos_protos.h>
  957. X#include <clib/exec_protos.h>
  958. X#include <clib/sregexp_protos.h>
  959. X
  960. XPrototype void            backup(int);
  961. XPrototype char *        getbackline(int *);
  962. XPrototype int            displines(char *);
  963. XPrototype char *        skipdispline(char *);
  964. XPrototype void            downone(void);
  965. XPrototype long            skiponeline(long);
  966. XPrototype int            breakfn(void);
  967. XPrototype void            bottomline(void);
  968. XPrototype int            searchfor(void);
  969. XPrototype void            nextpat(void);
  970. XPrototype void            prevpat(void);
  971. XPrototype void            behelpfull(void);
  972. XPrototype void            chkabort(void);
  973. XPrototype void            uponeline(void);
  974. X
  975. Xextern const char memory[],nolast[],nopat[],wait[],abort[];
  976. X
  977. Xextern char seek;
  978. Xextern long startpos,nextpos;
  979. Xextern FILE *file,*ofile;
  980. Xextern BPTR con;
  981. Xextern int sx,sy;
  982. Xextern struct SregExp *lastspat;
  983. X
  984. Xextern struct ExecBase *SysBase;
  985. X
  986. Xvoid
  987. Xbackup(n)
  988. Xint n;
  989. X{
  990. X    char *p,*q,*h;
  991. X    int l = 0;
  992. X
  993. X    show_line;
  994. X    do {
  995. X    if (l)
  996. X        free(p);
  997. X    if (!(p = getbackline(&startpos)))
  998. X        break;
  999. X    l += displines(p);
  1000. X    } while (l < n);
  1001. X
  1002. X    h = p;
  1003. X    while (l > n) {
  1004. X    q = skipdispline(p);
  1005. X    startpos += q - p;
  1006. X    p = q;
  1007. X    l-- ;
  1008. X    }
  1009. X    if (h)
  1010. X    free(h);
  1011. X    refreshscreen();
  1012. X}
  1013. X
  1014. Xchar *
  1015. Xgetbackline(pos)
  1016. Xlong *pos;
  1017. X{
  1018. X    char *p,c;
  1019. X    int l = 0;
  1020. X
  1021. X    show_line;
  1022. X    if (*pos == 0)
  1023. X    return NULL;
  1024. X    sseekbot(file,*pos-1);
  1025. X    while (*pos > 0) {
  1026. X    c = sgetcur(file);
  1027. X    if (c == '\n' && l != 0) {
  1028. X        sseek(file,+1,SEEK_CUR);
  1029. X        break;
  1030. X    }
  1031. X    sseek(file,-1,SEEK_CUR);
  1032. X    l++;
  1033. X    (*pos)--;
  1034. X    }
  1035. X    if (!(p = malloc(l+1)))
  1036. X    leave(12,memory);
  1037. X    sgets(p,l+1,file);
  1038. X    return p;
  1039. X}
  1040. X
  1041. Xint
  1042. Xdisplines(p)
  1043. Xchar *p;
  1044. X{
  1045. X    int l = 1;
  1046. X
  1047. X    show_line;
  1048. X    while (*(p = skipdispline(p))) l++;
  1049. X    return l;
  1050. X}
  1051. X
  1052. Xchar *
  1053. Xskipdispline(p)
  1054. Xchar *p;
  1055. X{
  1056. X    int l = 0;
  1057. X
  1058. X    show_line;
  1059. X    while (*p && l < sx) {
  1060. X    switch (*p++) {
  1061. X        case (12) :
  1062. X        return (l + 2 <= sx) ? p : p - 1;
  1063. X        case ((char)0x1b) :
  1064. X        if (*p != '[')
  1065. X            break;
  1066. X        p++;
  1067. X        case ((char)0x9b) :
  1068. X        while (isdigit(*p) || *p == ';' || *p == ' ')
  1069. X            p++;
  1070. X        p++;
  1071. X        break;
  1072. X        case (9) :
  1073. X        l = (l + 8) & (~7);
  1074. X        if (l > sx)
  1075. X            return p-1;
  1076. X        break;
  1077. X        case ('\n') :
  1078. X        return p;
  1079. X        default :
  1080. X        l++;
  1081. X    }
  1082. X    }
  1083. X    while ((*p == 0x1B && *(p+1) == '[') || *p == (char)0x9b) {
  1084. X    if (*p == 0x1b)
  1085. X        p++;
  1086. X    do {
  1087. X        p++;
  1088. X    } while (isdigit(*p) || *p == ';' || *p == ' ');
  1089. X    p++;
  1090. X    }
  1091. X    if (*p == '\n')
  1092. X    p++;
  1093. X    return p;
  1094. X}
  1095. X
  1096. Xvoid
  1097. Xdownone()
  1098. X{
  1099. X    int pos;
  1100. X
  1101. X    show_line;
  1102. X    if (seek) {
  1103. X    pos = stell(file);
  1104. X    startpos = skiponeline(startpos);
  1105. X    sseek(file,pos,SEEK_SET);
  1106. X    }
  1107. X    bottomline();
  1108. X    if (seek)
  1109. X    nextpos = stell(file);
  1110. X    putline();
  1111. X    if (seof(file))
  1112. X    nextpos = -1;
  1113. X    putconstr(": ",con);
  1114. X}
  1115. X
  1116. Xlong
  1117. Xskiponeline(pos)
  1118. Xlong pos;
  1119. X{
  1120. X    char *p,*q;
  1121. X
  1122. X    show_line;
  1123. X    sseek(file,pos,SEEK_SET);
  1124. X    if (!(p = sgetline(file)))
  1125. X    return pos;
  1126. X    q = skipdispline(p);
  1127. X    free(p);
  1128. X    return pos + q - p;
  1129. X}
  1130. X
  1131. Xvoid
  1132. Xuponeline()
  1133. X{
  1134. X    char *p,*h,*q;
  1135. X    int l,j;
  1136. X    long t;
  1137. X
  1138. X    h = p = getbackline(&startpos);
  1139. X    l = displines(p);
  1140. X    while (l > 1) {
  1141. X    q = skipdispline(p);
  1142. X    startpos += q - p;
  1143. X    p = q;
  1144. X    l--;
  1145. X    }
  1146. X    free(h);
  1147. X    if (nextpos < 0) {
  1148. X    sseek(file,startpos,SEEK_SET);
  1149. X    l = 0;
  1150. X    while ((p = sgetline(file)) && (l += displines(p)) < sy - 2) {
  1151. X        free(p);
  1152. X    }
  1153. X    if (p) {
  1154. X        nextpos = stell(file);
  1155. X        if (l > sy - 2) {
  1156. X        j = displines(p);
  1157. X        q = p;
  1158. X        while (l - j < sy - 2) {
  1159. X            q = skipdispline(q);
  1160. X            j--;
  1161. X        }
  1162. X        nextpos -= p + strlen(p) - q;
  1163. X        }
  1164. X        free(p);
  1165. X    } else
  1166. X        nextpos = -1;
  1167. X    } else {
  1168. X    h = p = getbackline(&nextpos);
  1169. X    l = displines(p);
  1170. X    while (l > 1) {
  1171. X        q = skipdispline(p);
  1172. X        nextpos += q - p;
  1173. X        p = q;
  1174. X        l-- ;
  1175. X    }
  1176. X    free(h);
  1177. X    }
  1178. X    sseek(file,startpos,SEEK_SET);
  1179. X    putconstr("\x9b0 p\x9bT\x9b0;0;H",con);
  1180. X    putline();
  1181. X    bottomline();
  1182. X    putconstr(": \x9b p",con);
  1183. X    t = skiponeline(nextpos);
  1184. X    sseek(file,t,SEEK_SET);
  1185. X}
  1186. X
  1187. Xint
  1188. Xbreakfn()
  1189. X{
  1190. X    show_line;
  1191. X    if (con) {
  1192. X    while (WaitForChar(con,100))
  1193. X        rawreadcon(con);
  1194. X    }
  1195. X    leave(5,"***BREAK***\n");
  1196. X}
  1197. X
  1198. Xvoid
  1199. Xbottomline()
  1200. X{
  1201. X    show_line;
  1202. X    putconchar('\x9b',con);
  1203. X    putconint(sy,con);
  1204. X    putconstr(";0H\x9bK",con);
  1205. X}
  1206. X
  1207. Xint
  1208. Xsearchfor()
  1209. X{
  1210. X    char *pat,buff[204];
  1211. X    struct SregExp *spat;
  1212. X
  1213. X    show_line;
  1214. X    if (!(pat = getstr(con))) {
  1215. X    bottomline();
  1216. X    putconstr(": ",con);
  1217. X    return FALSE;
  1218. X    }
  1219. X    if (!IsWild(pat)) {
  1220. X    strcpy(buff,"#?");
  1221. X    strcat(buff,pat);
  1222. X    strcat(buff,"#?");
  1223. X    } else {
  1224. X    strcpy(buff,pat);
  1225. X    strcat(buff,"\n");
  1226. X    }
  1227. X    free(pat);
  1228. X    if (!(spat = ParseSregExp(buff)))
  1229. X    return FALSE;
  1230. X    if (lastspat)
  1231. X    FreeSregExp(lastspat);
  1232. X    lastspat = spat;
  1233. X    return TRUE;
  1234. X}
  1235. X
  1236. Xvoid
  1237. Xnextpat()
  1238. X{
  1239. X    long h,i;
  1240. X    char *p;
  1241. X    struct Task *task = SysBase->ThisTask;
  1242. X
  1243. X    show_line;
  1244. X    if (!lastspat) {
  1245. X    bottomline();
  1246. X    putconstr(nolast,con);
  1247. X    return;
  1248. X    }
  1249. X    bottomline();
  1250. X    putconstr(wait,con);
  1251. X    h = startpos;
  1252. X    i = stell(file);
  1253. X    sseek(file,startpos,SEEK_SET);
  1254. X    p = sgetline(file);
  1255. X    free(p);
  1256. X    startpos = stell(file);
  1257. X    while (p = sgetline(file)) {
  1258. X    if (MatchSregExp(p,lastspat,FALSE)) {
  1259. X        free(p);
  1260. X        refreshscreen();
  1261. X        return;
  1262. X    }
  1263. X    free(p);
  1264. X    startpos = stell(file);
  1265. X    if (task->tc_SigRecvd & SIGBREAKF_CTRL_C) {
  1266. X        SetSignal(0, SIGBREAKF_CTRL_C);
  1267. X        bottomline();
  1268. X        putconstr(abort,con);
  1269. X        goto done;
  1270. X    }
  1271. X    }
  1272. X    bottomline();
  1273. X    putconstr(nopat,con);
  1274. Xdone:
  1275. X    startpos = h;
  1276. X    sseek(file,i,SEEK_SET);
  1277. X}
  1278. X
  1279. Xvoid
  1280. Xprevpat()
  1281. X{
  1282. X    long h,i;
  1283. X    char *p;
  1284. X    struct Task *task = SysBase->ThisTask;
  1285. X
  1286. X    show_line;
  1287. X    if (!lastspat) {
  1288. X    bottomline();
  1289. X    putconstr(nolast,con);
  1290. X    return;
  1291. X    }
  1292. X    bottomline();
  1293. X    putconstr(wait,con);
  1294. X    h = startpos;
  1295. X    i = stell(file);
  1296. X    while (p = getbackline(&startpos)) {
  1297. X    if (MatchSregExp(p,lastspat,FALSE)) {
  1298. X        free(p);
  1299. X        refreshscreen();
  1300. X        return;
  1301. X    }
  1302. X    free(p);
  1303. X    if (task->tc_SigRecvd & SIGBREAKF_CTRL_C) {
  1304. X        SetSignal(0, SIGBREAKF_CTRL_C);
  1305. X        bottomline();
  1306. X        putconstr(abort,con);
  1307. X        goto done;
  1308. X    }
  1309. X    }
  1310. X    bottomline();
  1311. X    putconstr(nopat,con);
  1312. Xdone:
  1313. X    startpos = h;
  1314. X    sseek(file,i,SEEK_SET);
  1315. X}
  1316. X
  1317. Xvoid
  1318. Xbehelpfull()
  1319. X{
  1320. X    char oseek;
  1321. X    long ostartpos,onextpos;
  1322. X
  1323. X    show_line;
  1324. X    ofile = file;
  1325. X    oseek = seek;
  1326. X    ostartpos = startpos;
  1327. X    onextpos = nextpos;
  1328. X    seek = TRUE;
  1329. X    file = sopen(NULL);
  1330. X    startpos = 0;
  1331. X    refreshscreen();
  1332. X    waitcommand();
  1333. X    sclose(file);
  1334. X    file = ofile;
  1335. X    ofile = NULL;
  1336. X    seek = oseek;
  1337. X    startpos = ostartpos;
  1338. X    nextpos = onextpos;
  1339. X    refreshscreen();
  1340. X}
  1341. X
  1342. Xvoid
  1343. Xchkabort(void)
  1344. X{
  1345. X    struct Task *task = SysBase->ThisTask;
  1346. X
  1347. X    if (task->tc_SigRecvd & SIGBREAKF_CTRL_C) {
  1348. X    SetSignal(0, SIGBREAKF_CTRL_C);
  1349. X    breakfn();
  1350. X    }
  1351. X}
  1352. X
  1353. END_OF_FILE
  1354. if test 6670 -ne `wc -c <'src/sless_1.c'`; then
  1355.     echo shar: \"'src/sless_1.c'\" unpacked with wrong size!
  1356. fi
  1357. # end of 'src/sless_1.c'
  1358. fi
  1359. if test -f 'src/sless_defs.h' -a "${1}" != "-c" ; then 
  1360.   echo shar: Will not clobber existing file \"'src/sless_defs.h'\"
  1361. else
  1362. echo shar: Extracting \"'src/sless_defs.h'\" \(975 characters\)
  1363. sed "s/^X//" >'src/sless_defs.h' <<'END_OF_FILE'
  1364. X
  1365. X#define Prototype   extern
  1366. X
  1367. X#include <exec/types.h>
  1368. X#include <libraries/dos.h>
  1369. X
  1370. X#ifdef __DEBUG__
  1371. X#ifdef __TRACE__
  1372. Xstatic const char __BaseFile[] = __BASE_FILE__;
  1373. X#define     show_line        reportline(__BaseFile,__LINE__)
  1374. X#else  (__TRACE__)
  1375. X#define     show_line
  1376. X#endif (__TRACE__)
  1377. X#else (__DEBUG__)
  1378. X#define     show_line
  1379. X#endif (__DEBUG__)
  1380. X
  1381. X
  1382. X#define VERSION     "1.1"
  1383. X
  1384. X#define MAXLINE     400
  1385. X
  1386. X#define makeconid(a,b)      ( ((short)(a) << 8) + (b) )
  1387. X
  1388. Xstruct conreport {
  1389. X    short    conid;
  1390. X    int     args[8];
  1391. X};
  1392. X
  1393. X
  1394. X
  1395. X#define getc(fp)        (((fp)->unget!=0x100||(fp)->pos>=(fp)->bufflen)?sgetc(fp):(fp)->buff[(fp)->pos++])
  1396. X#define seof(fp)        ((fp)->bufflen<=0)
  1397. X#define stell(fp)       ((fp)->filepos+(fp)->pos)
  1398. X#define ungetc(c,fp)    ((fp)->pos--,fp->unget=(c))
  1399. X
  1400. X#define SEEK_SET    0
  1401. X#define SEEK_CUR    1
  1402. X#define SEEK_END    2
  1403. X
  1404. Xtypedef struct file {
  1405. X    int     filepos,pos,bufflen;
  1406. X    BPTR    des;
  1407. X    short   unget;
  1408. X    char    *buff;
  1409. X} FILE;
  1410. X
  1411. X#include "sless_proto.h"
  1412. END_OF_FILE
  1413. if test 975 -ne `wc -c <'src/sless_defs.h'`; then
  1414.     echo shar: \"'src/sless_defs.h'\" unpacked with wrong size!
  1415. fi
  1416. # end of 'src/sless_defs.h'
  1417. fi
  1418. if test -f 'src/sless_file.c' -a "${1}" != "-c" ; then 
  1419.   echo shar: Will not clobber existing file \"'src/sless_file.c'\"
  1420. else
  1421. echo shar: Extracting \"'src/sless_file.c'\" \(5265 characters\)
  1422. sed "s/^X//" >'src/sless_file.c' <<'END_OF_FILE'
  1423. X
  1424. X#include "sless_defs.h"
  1425. X#include "sless_help.h"
  1426. X#include <stdlib.h>
  1427. X#include <string.h>
  1428. X#include <libraries/dos.h>
  1429. X#include <clib/dos_protos.h>
  1430. X
  1431. Xextern const char memory[];
  1432. X
  1433. XPrototype FILE *        sopen(char *);
  1434. XPrototype void            sclose(FILE *);
  1435. XPrototype char *        sgets(char *, int, FILE *);
  1436. XPrototype char *        sgetline(FILE *);
  1437. XPrototype char            sgetc(FILE *);
  1438. XPrototype void            sseek(FILE *, int, int);
  1439. XPrototype char            sgetcur(FILE *);
  1440. XPrototype void            sseekbot(FILE *, int);
  1441. XPrototype void            sputs(char *);
  1442. X
  1443. X#define FILEBUFF    2048
  1444. X
  1445. XFILE *
  1446. Xsopen(n)
  1447. Xchar *n;
  1448. X{
  1449. X    FILE *fp;
  1450. X
  1451. X    show_line;
  1452. X    if (!(fp = malloc(sizeof(FILE))))
  1453. X    leave(12,memory);
  1454. X    if (n == NULL) {
  1455. X    if (helplen == -1)
  1456. X        helplen = strlen(helpstr);
  1457. X    fp->des = 0;
  1458. X    fp->bufflen = helplen;
  1459. X    fp->buff = helpstr;
  1460. X    } else {
  1461. X    if (!(fp->des = Open(n,MODE_OLDFILE))) {
  1462. X        free(fp);
  1463. X        return NULL;
  1464. X    }
  1465. X    if (!(fp->buff = malloc(FILEBUFF)))
  1466. X        leave(12,memory);
  1467. X    fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
  1468. X    }
  1469. X    fp->filepos = 0;
  1470. X    fp->pos = 0;
  1471. X    fp->unget = 0x100;
  1472. X    return fp;
  1473. X}
  1474. X
  1475. Xvoid
  1476. Xsclose(fp)
  1477. XFILE *fp;
  1478. X{
  1479. X    show_line;
  1480. X    if (fp->des) {
  1481. X    Close(fp->des);
  1482. X    free(fp->buff);
  1483. X    }
  1484. X    free(fp);
  1485. X}
  1486. X
  1487. Xchar
  1488. Xsgetc(fp)
  1489. XFILE *fp;
  1490. X{
  1491. X    show_line;
  1492. X    if (fp->unget != 0x100) {
  1493. X    char c;
  1494. X    c = fp->unget;
  1495. X    fp->unget = 0x100;
  1496. X    fp->pos++;
  1497. X    return c;
  1498. X    }
  1499. X
  1500. X    if (fp->pos >= fp->bufflen) {
  1501. X    fp->filepos += fp->bufflen;
  1502. X    fp->bufflen = fp->des ? Read(fp->des,fp->buff,FILEBUFF) : 0;
  1503. X    if (seof(fp))
  1504. X        return 0;
  1505. X    fp->pos = 0;
  1506. X    }
  1507. X    return fp->buff[fp->pos++];
  1508. X}
  1509. X
  1510. Xchar *
  1511. Xsgets(p,n,fp)
  1512. Xchar *p;
  1513. Xint n;
  1514. XFILE *fp;
  1515. X{
  1516. X    char *q = p;
  1517. X
  1518. X    show_line;
  1519. X    sgetcur(fp);
  1520. X    if (seof(fp))
  1521. X    return NULL;
  1522. X    while (q - p < n-1 && (*q++ = getc(fp)) != '\n') {
  1523. X    if (seof(fp)) {
  1524. X        *--q = 0;
  1525. X        return p;
  1526. X    }
  1527. X    }
  1528. X    *q = 0;
  1529. X    return p;
  1530. X};
  1531. X
  1532. X#define START_SIZE  100
  1533. X#define UP_SIZE     20
  1534. X
  1535. Xchar *
  1536. Xsgetline(fp)
  1537. XFILE *fp;
  1538. X{
  1539. X    char *q = malloc(START_SIZE),*p;
  1540. X    int l = START_SIZE;
  1541. X
  1542. X    show_line;
  1543. X    p = q;
  1544. X    sgetcur(fp);
  1545. X    if (seof(fp))
  1546. X    return NULL;
  1547. X    while ((*q++ = getc(fp)) != '\n' && *(q-1) != 12) {
  1548. X    if (seof(fp)) {
  1549. X        *(q-1) = 0;
  1550. X        return p;
  1551. X    }
  1552. X    if (q - p == l) {
  1553. X        if (!(p = realloc(p,l += UP_SIZE)))
  1554. X        leave(12,memory);
  1555. X        q = p + l - UP_SIZE;
  1556. X    }
  1557. X    }
  1558. X    *q = 0;
  1559. X    return p;
  1560. X}
  1561. X
  1562. Xchar
  1563. Xsgetcur(fp)
  1564. XFILE *fp;
  1565. X{
  1566. X    show_line;
  1567. X    if (fp->unget != 0x100) {
  1568. X    return fp->unget;
  1569. X    }
  1570. X
  1571. X    if (fp->pos >= fp->bufflen) {
  1572. X    fp->filepos += fp->bufflen;
  1573. X    fp->bufflen = fp->des ? Read(fp->des,fp->buff,FILEBUFF) : 0;
  1574. X    if (seof(fp))
  1575. X        return 0;
  1576. X    fp->pos = 0;
  1577. X    }
  1578. X    return fp->buff[fp->pos];
  1579. X}
  1580. X
  1581. Xvoid
  1582. Xsseek(fp,p,t)
  1583. XFILE *fp;
  1584. Xint p,t;
  1585. X{
  1586. X    show_line;
  1587. X    fp->unget = 0x100;
  1588. X    switch (t) {
  1589. X    case (SEEK_SET) :
  1590. X        if (p >= fp->filepos && p < fp->filepos+fp->bufflen)
  1591. X        fp->pos = p - fp->filepos;
  1592. X        else {
  1593. X        if (!fp->des) {
  1594. X            if (p <= helplen) {
  1595. X            fp->filepos = 0;
  1596. X            fp->bufflen = helplen;
  1597. X            fp->pos = p;
  1598. X            } else
  1599. X            fp->bufflen = 0;
  1600. X        } else {
  1601. X            fp->filepos = p;
  1602. X            fp->pos = 0;
  1603. X            if (Seek(fp->des,p,OFFSET_BEGINNING) == -1)
  1604. X            fp->bufflen = 0;
  1605. X            else
  1606. X            fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
  1607. X        }
  1608. X        }
  1609. X        break;
  1610. X    case (SEEK_CUR) :
  1611. X        if ((p < 0 && fp->pos >= -p) ||
  1612. X                     (p >= 0 && p + fp->pos < fp->bufflen))
  1613. X        fp->pos += p;
  1614. X        else {
  1615. X        if (!fp->des) {
  1616. X            if (p + fp->pos <= helplen) {
  1617. X            fp->filepos = 0;
  1618. X            fp->bufflen = helplen;
  1619. X            fp->pos += p;
  1620. X            } else
  1621. X            fp->bufflen = 0;
  1622. X        } else {
  1623. X            if (p < 0)
  1624. X            sseekbot(fp,fp->filepos + fp->pos + p);
  1625. X            else {
  1626. X            fp->filepos += fp->pos + p;
  1627. X            if (Seek(fp->des,fp->filepos,OFFSET_BEGINNING) == -1)
  1628. X                fp->bufflen = 0;
  1629. X            else
  1630. X                fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
  1631. X            fp->pos = 0;
  1632. X            }
  1633. X        }
  1634. X        }
  1635. X        break;
  1636. X    case (SEEK_END) :
  1637. X        if (!fp->des) {
  1638. X        if (p >= 0 && -p <= helplen) {
  1639. X            fp->filepos = 0;
  1640. X            fp->bufflen = helplen;
  1641. X            fp->pos = helplen+p;
  1642. X        } else
  1643. X            fp->bufflen = 0;
  1644. X        } else {
  1645. X        Seek(fp->des,p,OFFSET_END);
  1646. X        fp->filepos = Seek(fp->des,0,OFFSET_CURRENT);
  1647. X        fp->pos = 0;
  1648. X        fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
  1649. X        }
  1650. X        break;
  1651. X    }
  1652. X}
  1653. X
  1654. Xvoid
  1655. Xsseekbot(fp,p)
  1656. XFILE *fp;
  1657. Xint p;
  1658. X{
  1659. X    show_line;
  1660. X    if (p >= fp->filepos && p <= fp->filepos+fp->bufflen)
  1661. X    fp->pos = p - fp->filepos;
  1662. X    else {
  1663. X    if (!fp->des)
  1664. X        sseek(fp,p,SEEK_SET);
  1665. X    else {
  1666. X        fp->filepos = p - FILEBUFF + 1;
  1667. X        if (fp->filepos < 0)
  1668. X        fp->filepos = 0;
  1669. X        if (Seek(fp->des,fp->filepos,OFFSET_BEGINNING) == -1)
  1670. X        fp->bufflen = 0;
  1671. X        else
  1672. X        fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
  1673. X        fp->pos = p - fp->filepos;
  1674. X    }
  1675. X    }
  1676. X}
  1677. X
  1678. Xvoid
  1679. Xsputs(p)
  1680. Xchar *p;
  1681. X{
  1682. X    chkabort();
  1683. X    Write(Output(),p,strlen(p));
  1684. X}
  1685. X
  1686. X#ifdef __DEBUG__
  1687. X
  1688. XPrototype void putint(int);
  1689. X
  1690. Xvoid
  1691. Xputint(i)
  1692. Xint i;
  1693. X{
  1694. X    int m = 1000000,f = FALSE;
  1695. X    char buf[9],*p = buf;
  1696. X
  1697. X    for ( ; m ; m /= 10) {
  1698. X    if (f || i >= m || m == 1) {
  1699. X        *p++ = (i / m + '0');
  1700. X        f = TRUE;
  1701. X        i %= m;
  1702. X    }
  1703. X    }
  1704. X    *p = 0;
  1705. X    sputs(buf);
  1706. X}
  1707. X
  1708. XPrototype void putchar(char);
  1709. X
  1710. Xvoid
  1711. Xputchar(c)
  1712. Xchar c;
  1713. X{
  1714. X    Write(Output(),&c,1);
  1715. X}
  1716. X
  1717. X#ifdef __TRACE__
  1718. X
  1719. XPrototype void reportline(char *, int);
  1720. X
  1721. Xvoid
  1722. Xreportline(name,line)
  1723. Xchar *name;
  1724. Xint line;
  1725. X{
  1726. X    sputs("Passing by file ");
  1727. X    sputs(name);
  1728. X    sputs(" line ");
  1729. X    putint(line);
  1730. X    putchar('\n');
  1731. X}
  1732. X
  1733. X#endif (__TRACE__)
  1734. X
  1735. X#endif (__DEBUG__)
  1736. END_OF_FILE
  1737. if test 5265 -ne `wc -c <'src/sless_file.c'`; then
  1738.     echo shar: \"'src/sless_file.c'\" unpacked with wrong size!
  1739. fi
  1740. # end of 'src/sless_file.c'
  1741. fi
  1742. if test -f 'src/sless_help.h' -a "${1}" != "-c" ; then 
  1743.   echo shar: Will not clobber existing file \"'src/sless_help.h'\"
  1744. else
  1745. echo shar: Extracting \"'src/sless_help.h'\" \(1056 characters\)
  1746. sed "s/^X//" >'src/sless_help.h' <<'END_OF_FILE'
  1747. X
  1748. Xint helplen = -1;
  1749. X
  1750. Xconst char helpstr[] =
  1751. X"\n"\
  1752. X"                          Sless V"\
  1753. XVERSION\
  1754. X"\n"\
  1755. X"                        by Jon Spencer\n"\
  1756. X"\n"\
  1757. X"     <space>...............Advance text one page.\n"\
  1758. X"     <backspace> or 'b'....Move back one page.\n"\
  1759. X"     'd'...................Move down half of a page.\n"\
  1760. X"     'u'...................Move up half of a page.\n"\
  1761. X"     <return> or\n"\
  1762. X"      <down arrow>.........Move down one line.\n"\
  1763. X"     <up arrow>............Move up one line.\n"\
  1764. X"     '<' or\n"\
  1765. X"      <shift><up arrow>....Move to the top of the file.\n"\
  1766. X"     '>' or\n"\
  1767. X"      <shift><down arrow>..Move to the bottom of the file.\n"\
  1768. X"     '/'...................Search forward for a pattern.\n"\
  1769. X"     ';'...................Search backward for a pattern.\n"\
  1770. X"     'n'...................Search for next occurance of last pattern.\n"\
  1771. X"     'p'...................Search for previous occurance of last pattern.\n"\
  1772. X"     '?' or 'h' or <help>..This help page.\n"\
  1773. X"     'q'...................quit (press this to return to the file.)\n"
  1774. X;
  1775. END_OF_FILE
  1776. if test 1056 -ne `wc -c <'src/sless_help.h'`; then
  1777.     echo shar: \"'src/sless_help.h'\" unpacked with wrong size!
  1778. fi
  1779. # end of 'src/sless_help.h'
  1780. fi
  1781. if test -f 'src/sless_win.c' -a "${1}" != "-c" ; then 
  1782.   echo shar: Will not clobber existing file \"'src/sless_win.c'\"
  1783. else
  1784. echo shar: Extracting \"'src/sless_win.c'\" \(6660 characters\)
  1785. sed "s/^X//" >'src/sless_win.c' <<'END_OF_FILE'
  1786. X
  1787. X#include <sless_defs.h>
  1788. X#include <string.h>
  1789. X#include <stdlib.h>
  1790. X#include <ctype.h>
  1791. X#include <libraries/dosextens.h>
  1792. X#include <intuition/intuition.h>
  1793. X#include <clib/dos_protos.h>
  1794. X#include <clib/intuition_protos.h>
  1795. X#include <clib/exec_protos.h>
  1796. X
  1797. XPrototype BPTR            makeoutput(char *);
  1798. XPrototype void            closeoutput(BPTR);
  1799. XPrototype LONG            stdpkt(LONG, LONG, BPTR);
  1800. XPrototype void            setupcon(BPTR);
  1801. XPrototype void            putconstr(char *, BPTR);
  1802. XPrototype void            putconchar(char, BPTR);
  1803. XPrototype short         getconchar(BPTR);
  1804. XPrototype char            rawreadcon(BPTR);
  1805. XPrototype struct conreport *    getconreport(short, BPTR);
  1806. XPrototype struct conreport *    readconreport(BPTR);
  1807. XPrototype void            windowresized(BPTR);
  1808. XPrototype char *        getstr(BPTR);
  1809. XPrototype void            findsize(int *, int *, BPTR);
  1810. XPrototype void            sto_char(short);
  1811. XPrototype short         get_sto(void);
  1812. XPrototype void            putconint(int, BPTR);
  1813. X
  1814. Xextern const char memory[];
  1815. Xstatic char *oldname;
  1816. X
  1817. Xextern int sx,sy;
  1818. Xextern char seek;
  1819. X
  1820. XBPTR
  1821. Xmakeoutput(n)
  1822. Xchar *n;
  1823. X{
  1824. X    BPTR con;
  1825. X    struct MsgPort *cport;
  1826. X    __aligned struct InfoData id;
  1827. X    struct Window *win;
  1828. X    char buff[77];
  1829. X
  1830. X    show_line;
  1831. X    if (!IsInteractive(con = Output())) {
  1832. X    strcpy(buff,"con:0/1/640/199/");
  1833. X    strncat(buff,n,60);
  1834. X    if (!(con = Open(buff,MODE_NEWFILE)))
  1835. X        leave(15,"sless: Unable to obtain a display.\n");
  1836. X    } else {
  1837. X    stdpkt(ACTION_DISK_INFO,(LONG)(&id >> 2),con);
  1838. X    win = (struct Window *)(id.id_VolumeNode);
  1839. X    oldname = win->Title;
  1840. X    SetWindowTitles(win,n,(char *)-1);
  1841. X    }
  1842. X    setupcon(con);
  1843. X    return con;
  1844. X}
  1845. X
  1846. Xvoid
  1847. Xcloseoutput(con)
  1848. XBPTR con;
  1849. X{
  1850. X    struct MsgPort *cport;
  1851. X    __aligned struct InfoData id;
  1852. X    struct Window *win;
  1853. X
  1854. X    show_line;
  1855. X    if (con != Output()) {
  1856. X    Close(con);
  1857. X    return;
  1858. X    }
  1859. X
  1860. X    stdpkt(ACTION_DISK_INFO,(LONG)(&id >> 2),con);
  1861. X    win = (struct Window *)(id.id_VolumeNode);
  1862. X    SetWindowTitles(win,oldname,(char *)-1);
  1863. X    stdpkt(ACTION_SCREEN_MODE,0,con);
  1864. X    putconstr("\x9b p",con);
  1865. X}
  1866. X
  1867. XLONG
  1868. Xstdpkt(type,arg,con)
  1869. XLONG type,arg;
  1870. XBPTR con;
  1871. X{
  1872. X    __aligned struct StandardPacket pkt;
  1873. X    struct MsgPort *reply,*who;
  1874. X
  1875. X    show_line;
  1876. X    who = ((struct FileHandle *)(con << 2))->fh_Type;
  1877. X
  1878. X    if (!(reply = CreatePort(NULL,0)))
  1879. X    leave(15,"sless: Unable to send packet");
  1880. X
  1881. X    pkt.sp_Msg.mn_Node.ln_Name = (char *)&(pkt.sp_Pkt);
  1882. X    pkt.sp_Pkt.dp_Link = &(pkt.sp_Msg);
  1883. X    pkt.sp_Pkt.dp_Port = reply;
  1884. X    pkt.sp_Pkt.dp_Type = type;
  1885. X    pkt.sp_Pkt.dp_Arg1 = arg;
  1886. X    PutMsg(who,&(pkt.sp_Msg));
  1887. X    WaitPort(reply);
  1888. X    GetMsg(reply);
  1889. X
  1890. X    DeletePort(reply);
  1891. X
  1892. X    return pkt.sp_Pkt.dp_Res1;
  1893. X}
  1894. X
  1895. Xvoid
  1896. Xsetupcon(con)
  1897. XBPTR con;
  1898. X{
  1899. X    show_line;
  1900. X    stdpkt(ACTION_SCREEN_MODE,-1,con);
  1901. X    putconstr("\x9B20h\x9b12{",con);
  1902. X}
  1903. X
  1904. Xstruct conreport *
  1905. Xgetconreport(e,con)
  1906. Xshort e;
  1907. XBPTR con;
  1908. X{
  1909. X    char p;
  1910. X    struct conreport *cr;
  1911. X
  1912. X    show_line;
  1913. X    do {
  1914. X    while ((p = rawreadcon(con)) != (char)0x9B)
  1915. X        sto_char(p);
  1916. X
  1917. X    if (cr = readconreport(con)) {
  1918. X        if (cr->conid == e)
  1919. X        return cr;
  1920. X        else {
  1921. X        sto_char(cr->conid);
  1922. X        free(cr);
  1923. X        }
  1924. X    }
  1925. X    } while (TRUE);
  1926. X}
  1927. X
  1928. Xstruct conreport *
  1929. Xreadconreport(con)
  1930. XBPTR con;
  1931. X{
  1932. X    struct conreport *cr;
  1933. X    char p;
  1934. X    int i=0,v;
  1935. X
  1936. X    show_line;
  1937. X    if (!(cr = malloc(sizeof(struct conreport))))
  1938. X    leave(12,memory);
  1939. X
  1940. X    do {
  1941. X    v = 0;
  1942. X    p = rawreadcon(con);
  1943. X    while (isdigit(p)) {
  1944. X        v = v * 10 + p - '0';
  1945. X        p = rawreadcon(con);
  1946. X    }
  1947. X    cr->args[i++] = v;
  1948. X    } while (p == ';');
  1949. X    v = makeconid(p,0);
  1950. X    if (p == '?' || p == ' ') {
  1951. X    p = rawreadcon(con);
  1952. X    v = v + p;
  1953. X    }
  1954. X    cr->conid = v;
  1955. X    if (v == makeconid('|',0) && cr->args[0] == 12) {
  1956. X    windowresized(con);
  1957. X    return NULL;
  1958. X    }
  1959. X    return cr;
  1960. X}
  1961. X
  1962. Xshort
  1963. Xgetconchar(con)
  1964. XBPTR con;
  1965. X{
  1966. X    short p;
  1967. X    struct conreport *cr;
  1968. X
  1969. X    show_line;
  1970. X    do {
  1971. X    if (p = get_sto())
  1972. X        break;
  1973. X    if ((p = rawreadcon(con)) == (char)'\x9b') {
  1974. X        if (cr = readconreport(con)) {
  1975. X        p = cr->conid;
  1976. X        free(cr);
  1977. X        break;
  1978. X        }
  1979. X    } else
  1980. X        break;
  1981. X    } while (TRUE);
  1982. X    return p;
  1983. X}
  1984. X
  1985. Xchar
  1986. Xrawreadcon(con)
  1987. XBPTR con;
  1988. X{
  1989. X    char p;
  1990. X
  1991. X    show_line;
  1992. X    while (!WaitForChar(con,100000)) {
  1993. X    chkabort();
  1994. X    }
  1995. X    if (Read(con,&p,1) != 1)
  1996. X    return 0;
  1997. X    return p;
  1998. X}
  1999. X
  2000. Xvoid
  2001. Xputconchar(c,con)
  2002. Xchar c;
  2003. XBPTR con;
  2004. X{
  2005. X    show_line;
  2006. X    Write(con,&c,1);
  2007. X    chkabort();
  2008. X}
  2009. X
  2010. Xvoid
  2011. Xputconstr(p,con)
  2012. Xchar *p;
  2013. XBPTR con;
  2014. X{
  2015. X    show_line;
  2016. X    Write(con,p,strlen(p));
  2017. X    chkabort();
  2018. X}
  2019. X
  2020. Xvoid windowresized(con)
  2021. XBPTR con;
  2022. X{
  2023. X    show_line;
  2024. X    findsize(&sx,&sy,con);
  2025. X    if (seek)
  2026. X    refreshscreen();
  2027. X    else {
  2028. X    bottomline();
  2029. X    putconstr(": ",con);
  2030. X    }
  2031. X}
  2032. X
  2033. Xchar *
  2034. Xgetstr(con)
  2035. XBPTR con;
  2036. X{
  2037. X    short c;
  2038. X    char buff[200],*p = buff,*q;
  2039. X
  2040. X    show_line;
  2041. X    *p = 0;
  2042. X    do {
  2043. X    switch(c = getconchar(con)) {
  2044. X        case (13) :
  2045. X        goto end;
  2046. X        case (makeconid('D',0)) :
  2047. X        if (p != buff) {
  2048. X            putconstr("\x9bD",con);
  2049. X            p--;
  2050. X        }
  2051. X        break;
  2052. X        case (makeconid('C',0)) :
  2053. X        if (*p) {
  2054. X            putconstr("\x9bC",con);
  2055. X            p++;
  2056. X        }
  2057. X        break;
  2058. X        case (makeconid(' ','A')) :
  2059. X        if (p != buff) {
  2060. X            putconchar('\x9b',con);
  2061. X            putconint(p-buff,con);
  2062. X            putconchar('D',con);
  2063. X            p = buff;
  2064. X        }
  2065. X        break;
  2066. X        case (makeconid(' ','@')) :
  2067. X        if (*p) {
  2068. X            putconchar('\x9b',con);
  2069. X            putconint(strlen(p),con);
  2070. X            putconchar('C',con);
  2071. X            p += strlen(p);
  2072. X        }
  2073. X        break;
  2074. X        case (8) :
  2075. X        if (p != buff) {
  2076. X            putconstr("\x9bD\x9bP",con);
  2077. X            q = --p;
  2078. X            while (*q = *(q+1))
  2079. X            q++;
  2080. X        }
  2081. X        break;
  2082. X        case (127) :
  2083. X        if (*p) {
  2084. X            putconstr("\x9bP",con);
  2085. X            q = p;
  2086. X            while (*q = *(q+1))
  2087. X            q++;
  2088. X        }
  2089. X        default :
  2090. X        if (isprint(c)) {
  2091. X            putconstr("\x9b@",con);
  2092. X            putconchar(c,con);
  2093. X            q = p + strlen(p) + 1;
  2094. X            do {
  2095. X            *q = *(q-1);
  2096. X            q--;
  2097. X            } while (q != p);
  2098. X            *p++ = c;
  2099. X        }
  2100. X    }
  2101. X    } while (TRUE);
  2102. X
  2103. Xend:
  2104. X    if (strlen(buff) == 0)
  2105. X    return NULL;
  2106. X    if (!(p = malloc(strlen(buff)+1)))
  2107. X    leave(12,memory);
  2108. X    strcpy(p,buff);
  2109. X    return p;
  2110. X}
  2111. X
  2112. Xvoid
  2113. Xputconint(x,con)
  2114. Xint x;
  2115. XBPTR con;
  2116. X{
  2117. X    int v;
  2118. X    char p,f = FALSE;
  2119. X
  2120. X    show_line;
  2121. X    for (v = 1000000; v > 0; v /= 10) {
  2122. X    p = x / v;
  2123. X    x = x - p*v;
  2124. X    if (p != 0 || f) {
  2125. X        f = TRUE;
  2126. X        putconchar(p + '0',con);
  2127. X    }
  2128. X    }
  2129. X}
  2130. X
  2131. Xvoid
  2132. Xfindsize(x,y,con)
  2133. Xint *x,*y;
  2134. XBPTR con;
  2135. X{
  2136. X    struct conreport *cr;
  2137. X
  2138. X    show_line;
  2139. X    putconstr("\x9b0 q",con);
  2140. X
  2141. X    cr = getconreport(makeconid(' ','r'),con);
  2142. X
  2143. X    *x = cr->args[3];
  2144. X    *y = cr->args[2];
  2145. X    free(cr);
  2146. X}
  2147. X
  2148. X#define STO_LEN     100
  2149. Xstatic short sto_buff[STO_LEN];
  2150. Xstatic int sto_s = 0,sto_e = 0;
  2151. X
  2152. Xvoid
  2153. Xsto_char(e)
  2154. Xshort e;
  2155. X{
  2156. X    show_line;
  2157. X    sto_buff[sto_e] = e;
  2158. X    sto_e = (sto_e + 1) % STO_LEN;
  2159. X    if (sto_e == sto_s)             /* lost some off the end */
  2160. X    sto_s = (sto_s + 1) % STO_LEN;
  2161. X}
  2162. X
  2163. Xshort
  2164. Xget_sto()
  2165. X{
  2166. X    short c;
  2167. X
  2168. X    show_line;
  2169. X    if (sto_s == sto_e)
  2170. X    return 0;
  2171. X    c = sto_buff[sto_s];
  2172. X    sto_s = (sto_s + 1) % STO_LEN;
  2173. X    return c;
  2174. X}
  2175. X
  2176. END_OF_FILE
  2177. if test 6660 -ne `wc -c <'src/sless_win.c'`; then
  2178.     echo shar: \"'src/sless_win.c'\" unpacked with wrong size!
  2179. fi
  2180. # end of 'src/sless_win.c'
  2181. fi
  2182. if test -f 'src/sman.c' -a "${1}" != "-c" ; then 
  2183.   echo shar: Will not clobber existing file \"'src/sman.c'\"
  2184. else
  2185. echo shar: Extracting \"'src/sman.c'\" \(6498 characters\)
  2186. sed "s/^X//" >'src/sman.c' <<'END_OF_FILE'
  2187. X
  2188. X#include <stdlib.h>
  2189. X#include <stdio.h>
  2190. X#include <string.h>
  2191. X#include <ctype.h>
  2192. X#include <stdarg.h>
  2193. X#include <libraries/dos.h>
  2194. X#include <clib/dos_protos.h>
  2195. X#include <clib/exec_protos.h>
  2196. X#include <clib/sregexp_protos.h>
  2197. X#include <libraries/sregexpbase.h>
  2198. X#include "sman_defs.h"
  2199. X
  2200. XPrototype long        findman(char *, char *, char *, int);
  2201. XPrototype long        searchpath(char *, char *, char *, int);
  2202. XPrototype void        usage(void);
  2203. XPrototype long        okfile(char *, char *, char);
  2204. XPrototype void        putline(char *);
  2205. XPrototype void        leave(char *, int);
  2206. XPrototype char *    expandpath(char *, char *);
  2207. XPrototype int        spathbrk(void);
  2208. X
  2209. Xconst char memory[] = "sman: Unable to allocate memory.\n";
  2210. X
  2211. Xint
  2212. Xmain(ac,av)
  2213. Xint ac;
  2214. Xchar *av[];
  2215. X{
  2216. X    char *com,*path = NULL,file[MAXPATH],*viewer = NULL;
  2217. X    long line;
  2218. X
  2219. X    do {
  2220. X    if (--ac < 1 || **++av != '-')
  2221. X        break;
  2222. X    switch (*(*av+1)) {
  2223. X        case ('p') :
  2224. X        case ('P') :
  2225. X        if (!*(path = *av + 2)) {
  2226. X            ac--;
  2227. X            path = *(++av);
  2228. X        }
  2229. X        break;
  2230. X        case ('v') :
  2231. X        case ('V') :
  2232. X        if (!*(viewer = *av + 2)) {
  2233. X            ac--;
  2234. X            viewer = *(++av);
  2235. X        }
  2236. X        break;
  2237. X        default :
  2238. X        usage();
  2239. X    }
  2240. X    } while (1);
  2241. X    if (ac < 1)
  2242. X    usage();
  2243. X
  2244. X    if (!path)
  2245. X    if (!(path = getenv("SmanPath"))) {
  2246. X        putline("Environment Variable SmanPath not defined.\n");
  2247. X        return 1;
  2248. X    }
  2249. X    if (!viewer)
  2250. X    viewer = getenv("SmanViewer");
  2251. X
  2252. X    while (ac >= 1) {
  2253. X    if ((line = findman(av[0],path,file,MAXPATH)) != NOT_FOUND) {
  2254. X        if (viewer) {
  2255. X        if (!(com = malloc(strlen(viewer)+strlen(file)+2))) {
  2256. X            putline(memory);
  2257. X            return 5;
  2258. X        }
  2259. X        strcpy(com,viewer);
  2260. X        strcat(com," ");
  2261. X        strcat(com,file);
  2262. X        } else {
  2263. X        char f = FALSE;
  2264. X        int i,mod;
  2265. X
  2266. X        if (!(com = malloc(strlen(file)+17))) {
  2267. X            putline(memory);
  2268. X            return 5;
  2269. X        }
  2270. X        strcpy(com,"sless -");
  2271. X        if (line > 0)
  2272. X            com[7] = 'l';
  2273. X        else {
  2274. X            com[7] = 'c';
  2275. X            line = -line;
  2276. X        }
  2277. X        for (i = 8, mod = 10000000; mod != 0; mod /= 10) {
  2278. X            com[i] = line / mod + '0';
  2279. X            if (com[i] != '0' || f || mod == 1) {
  2280. X            f = TRUE;
  2281. X            i++;
  2282. X            }
  2283. X            line %= mod;
  2284. X        }
  2285. X        com[i++] = ' ';
  2286. X        strcpy(com+i,file);
  2287. X        }
  2288. X        system(com);
  2289. X    }
  2290. X    ac--;
  2291. X    av++;
  2292. X    }
  2293. X
  2294. X    return 0;
  2295. X}
  2296. X
  2297. Xlong
  2298. Xfindman(tar,p,file,len)
  2299. Xchar *tar,*p,*file;
  2300. Xint len;
  2301. X{
  2302. X    char *h,q;
  2303. X    long line;
  2304. X
  2305. X    do {
  2306. X    h = p;
  2307. X    while (*p != ';' && *p) p++;
  2308. X    q = *p;
  2309. X    *p = 0;
  2310. X    line = searchpath(h,tar,file,len);
  2311. X    *p++ = q;
  2312. X    if (line != NOT_FOUND)
  2313. X        return line;
  2314. X    } while (q);
  2315. X
  2316. X    putline("No manual entry found for '");
  2317. X    putline(tar);
  2318. X    putline("'.\n");
  2319. X    return NOT_FOUND;
  2320. X}
  2321. X
  2322. X/* This has to be global to free it on a break... */
  2323. Xstruct SpathInfo *spath = NULL;
  2324. X
  2325. Xlong
  2326. Xsearchpath(p,tar,file,len)
  2327. Xchar *p,*tar,*file;
  2328. Xint len;
  2329. X{
  2330. X    char *e;
  2331. X    long line,test;
  2332. X
  2333. X    if (!(e = expandpath(p + (*p == ADOC || *p == DREF ? 1 : 0),tar)))
  2334. X    return NOT_FOUND;
  2335. X
  2336. X    spath = AnchorPath("",e);
  2337. X    free(e);
  2338. X    if (!spath) {
  2339. X    putline("Illegal Path rule '");
  2340. X    putline(p);
  2341. X    putline("'\n");
  2342. X    return NOT_FOUND;
  2343. X    }
  2344. X
  2345. X    onbreak(&spathbrk);
  2346. X
  2347. X    line = NOT_FOUND;
  2348. X    do {
  2349. X    while ((test = NextFile(spath,file,len,SP_FILES_ONLY)) > 0) {
  2350. X        line = okfile(file,tar,*p);
  2351. X        if (line != NOT_FOUND)
  2352. X        break;
  2353. X    }
  2354. X    if (test == SPE_SIGBREAK) {
  2355. X        chkabort();
  2356. X        SetSignal(0,SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D|SIGBREAKF_CTRL_E|SIGBREAKF_CTRL_F);
  2357. X        test = 0;
  2358. X    }
  2359. X    } while (line == NOT_FOUND && test >= 0);
  2360. X    onbreak(NULL);
  2361. X    FreeSpathInfo(spath);
  2362. X    spath = NULL;
  2363. X    return line;
  2364. X}
  2365. X
  2366. Xint
  2367. Xspathbrk()
  2368. X{
  2369. X    if (spath)
  2370. X    FreeSpathInfo(spath);
  2371. X    return 1;
  2372. X}
  2373. X
  2374. Xlong
  2375. Xokfile(file,tar,ftype)
  2376. Xchar *file,*tar,ftype;
  2377. X{
  2378. X    FILE *fp;
  2379. X    char buff[200],*m,*n;
  2380. X    int line,len;
  2381. X    struct SregExp *spat;
  2382. X
  2383. X    if (ftype != ADOC && ftype != DREF)
  2384. X    return 0;
  2385. X
  2386. X    if (!(fp = fopen(file,"r")))
  2387. X    return NOT_FOUND;
  2388. X
  2389. X    if (ftype == ADOC) {
  2390. X    line = -1;
  2391. X    do {
  2392. X        if (fgets(buff,199,fp) != buff) {
  2393. X        fclose(fp);
  2394. X        return NOT_FOUND;
  2395. X        }
  2396. X        line++;
  2397. X    } while (*buff == '\n');
  2398. X
  2399. X    if (strnicmp("TABLE OF CONTENTS",buff,17)) {
  2400. X        fclose(fp);
  2401. X        return NOT_FOUND;
  2402. X    }
  2403. X
  2404. X    strcpy(buff,"#?/(");
  2405. X    strcat(buff,tar);
  2406. X    strcat(buff,")\n");
  2407. X    if (!(spat = ParseSregExp(buff))) {
  2408. X        fclose(fp);
  2409. X        return NOT_FOUND;
  2410. X    }
  2411. X    while (fgets(buff,199,fp) == buff) {
  2412. X        line++;
  2413. X        if (*buff == 12) {
  2414. X        FreeSregExp(spat);
  2415. X        fclose(fp);
  2416. X        return NOT_FOUND;
  2417. X        }
  2418. X        if (MatchSregExp(buff,spat,TRUE))
  2419. X        goto agotit;
  2420. X    }
  2421. X    FreeSregExp(spat);
  2422. X    fclose(fp);
  2423. X    return NOT_FOUND;
  2424. X
  2425. X    agotit:
  2426. X    FreeSregExp(spat);
  2427. X    len = strlen(buff);
  2428. X    buff[len-1] = 0;
  2429. X    if (!(m = malloc(len))) {
  2430. X        fclose(fp);
  2431. X        leave(memory,5);
  2432. X    }
  2433. X    strcpy(m,buff);
  2434. X    while (fgets(buff,199,fp) == buff) {
  2435. X        line++;
  2436. X        if (strncmp(m,buff,len - 1) == 0) {
  2437. X        free(m);
  2438. X        fclose(fp);
  2439. X        return line;
  2440. X        }
  2441. X    }
  2442. X    free(m);
  2443. X    fclose(fp);
  2444. X    return NOT_FOUND;
  2445. X    } else {
  2446. X    len = strlen(tar);
  2447. X    while (fgets(buff,199,fp) == buff) {
  2448. X        if (strncmp(tar,buff,len) == 0 && isspace(buff[len])) {
  2449. X        fclose(fp);
  2450. X        goto dgotit;
  2451. X        }
  2452. X    }
  2453. X    fclose(fp);
  2454. X    return NOT_FOUND;
  2455. X
  2456. X    dgotit:
  2457. X    m = buff;
  2458. X    for (len = 0; len < 2; len++) {
  2459. X        while (!isspace(*m++)) ;
  2460. X        while (isspace(*m)) m++;
  2461. X    }
  2462. X    n = m;
  2463. X    while (*n != ':' && *n != '/' && !isspace(*n)) n++;
  2464. X    if (*n == ':')
  2465. X        n = file;
  2466. X    else {
  2467. X        n = file + strlen(file);
  2468. X        while (*(n-1) != '/' && *(n-1) != ':' && n != file) n--;
  2469. X    }
  2470. X    while (!isspace(*m))
  2471. X        *n++ = *m++;
  2472. X    *n = 0;
  2473. X    while (isspace(*m)) m++;
  2474. X    if (*m++ != '@' || *m++ != '@')
  2475. X        return 0;
  2476. X    line = 0;
  2477. X    while (!isspace(*m))
  2478. X        line = line*10 - *m++ + '0';
  2479. X    return line;
  2480. X    }
  2481. X}
  2482. X
  2483. Xchar *
  2484. Xexpandpath(p,tar)
  2485. Xchar *p,*tar;
  2486. X{
  2487. X    int num = 0;
  2488. X    char *q,*r,*t;
  2489. X
  2490. X    for (q = p; *q; q++) {
  2491. X    if (*q == '\'' && *(q+1) == '&')
  2492. X        q++;
  2493. X    else if (*q == '&')
  2494. X        num++;
  2495. X    }
  2496. X
  2497. X    if (!(q = malloc(strlen(p) + num*(strlen(tar)+1) + 1))) {
  2498. X    putline(memory);
  2499. X    return NULL;
  2500. X    }
  2501. X
  2502. X    for (r = q; *p; p++) {
  2503. X    if (*p == '&') {
  2504. X        *r++ = '(';
  2505. X        for (t = tar; *t; t++)
  2506. X        *r++ = *t;
  2507. X        *r++ = ')';
  2508. X    } else {
  2509. X        if (*p == '\'' && *(p+1) == '&')
  2510. X        p++;
  2511. X        *r++ = *p;
  2512. X    }
  2513. X    }
  2514. X    *r = 0;
  2515. X    return q;
  2516. X}
  2517. X
  2518. Xvoid
  2519. Xusage()
  2520. X{
  2521. X    putline("sman V"\
  2522. X         VERSION\
  2523. X         ", "
  2524. X         __DATE__\
  2525. X         ", (c)Copyright 1991 by Jon Spencer.\n");
  2526. X    putline("Usage: Sman [-pSearch pattern] [-vViewer] target [target...]\n");
  2527. X    exit(2);
  2528. X}
  2529. X
  2530. Xvoid
  2531. Xputline(p)
  2532. Xchar *p;
  2533. X{
  2534. X    Write(Output(),p,strlen(p));
  2535. X}
  2536. X
  2537. Xvoid
  2538. Xleave(p,x)
  2539. Xchar *p;
  2540. Xint x;
  2541. X{
  2542. X    putline(p);
  2543. X    exit(x);
  2544. X}
  2545. X
  2546. Xint printf(f, ...)
  2547. Xconst char *f;
  2548. X{
  2549. X    char buff[100];
  2550. X    va_list va;
  2551. X
  2552. X    va_start(va,f);
  2553. X    vsprintf(buff,f,va);
  2554. X    va_end(va);
  2555. X    Write(Output(),buff,strlen(buff));
  2556. X}
  2557. END_OF_FILE
  2558. if test 6498 -ne `wc -c <'src/sman.c'`; then
  2559.     echo shar: \"'src/sman.c'\" unpacked with wrong size!
  2560. fi
  2561. # end of 'src/sman.c'
  2562. fi
  2563. if test -f 'src/sman.n' -a "${1}" != "-c" ; then 
  2564.   echo shar: Will not clobber existing file \"'src/sman.n'\"
  2565. else
  2566. echo shar: Extracting \"'src/sman.n'\" \(3852 characters\)
  2567. sed "s/^X//" >'src/sman.n' <<'END_OF_FILE'
  2568. X.*
  2569. X.*
  2570. X.TH SMAN 1 "AMIGA Programmer's Manual" "Jon Spencer" "Version 1.1"
  2571. X.SH NAME
  2572. Xsman - a document lookup program.
  2573. X.SH SYNOPSIS
  2574. X.bo "sman
  2575. X[-p Search Pattern] [-v Viewer] target [target...]
  2576. X.SH DESCRIPTION
  2577. XThere is no uniform standard for the format or position of documentation
  2578. Xfiles on the Amiga.  This makes a manual program in the style of the Unix
  2579. X.ul "man
  2580. Xprogram a somewhat difficult thing to create.
  2581. X.ul "sman
  2582. Xattempts to overcome this difficulty by allowing the user to
  2583. Xspecify quite general rules for the location of documentation
  2584. Xfiles. Once a document is located, it is passed on to a text viewer
  2585. Xto be displayed.
  2586. X
  2587. XThere are two ways the documentation lookup rules can be passed to
  2588. X.ul "sman.
  2589. XThe first is by the use of the
  2590. X.bo "-p
  2591. Xcommand line argument, the second is by the ENV: environment
  2592. Xvariable
  2593. X.bo "SmanPath.
  2594. XThe command line argument will override any definition of the
  2595. Xenvironment variable, but at least one must be defined.
  2596. X
  2597. XThe format of the lookup rule is:
  2598. X
  2599. X.in +5
  2600. Xrule1;rule2;...
  2601. X.in -5
  2602. X
  2603. XEach of the rules will be searched in order until a match is found.
  2604. XA rule is formed by an optional special character, which specifies
  2605. Xthe kind of search to be performed on the matching files, followed
  2606. Xby a (possibly) wildcarded AmigaDOS path specifying the
  2607. Xfiles to be searched.  See
  2608. X.ul "sregexp.doc
  2609. Xfor a discussion of the wildcard format.
  2610. X
  2611. XThere are currently three kinds of search rules implemented:
  2612. X
  2613. X.ta
  2614. X.in +4;.ta +0
  2615. X.de opt
  2616. X.ti -3;.bo "$0
  2617. X.en
  2618. X.opt Default
  2619. X@t If the rule does not start with one of the characters discussed
  2620. Xbelow, then no special search is done on the files on the path, and
  2621. X.ul "sman
  2622. Xwill succeed on the first file found.  There is a special wildcard character
  2623. Xdefined in sman to make this useful.  If the character '&' is found
  2624. Xin the search path, it will be expanded to the current target.
  2625. XFor example, if you typed 'sman test' and
  2626. X.bo "SmanPath
  2627. Xwas defined as 'DOCS:.../&.(doc|man)', then the path sman
  2628. Xwould try to match would be 'DOCS:.../(test).(doc|man)'.
  2629. X
  2630. X.opt @@
  2631. X@tIf this is the first character of the rule, then sman will assume
  2632. Xthe matched files are
  2633. X.ul "dme.refs
  2634. Xformat files, as used by Matt Dillon's
  2635. X.ul "dme
  2636. Xeditor.  The files will be searched for an entry matching the
  2637. Xtarget.
  2638. X.bp
  2639. X.opt +
  2640. X@tThis type of rule tells
  2641. X.ul "sman
  2642. Xthe matching files are Amiga
  2643. XAutodoc format files.  Each file on the path will be search
  2644. Xfor an entry matching the target.  For example, if
  2645. X.bo "SmanPath
  2646. Xwas '+Autodocs:#?/#?.doc', then 'sman Write' would match to
  2647. X.in +3
  2648. X'Autodocs:LibrariesA-K/dos.doc' (under 1.3 anyway).
  2649. X.in -7
  2650. X
  2651. XAll file name searches are case insensitive. All searches within
  2652. Xa file (for '+' and '@@' type rules) are case sensitive.
  2653. X
  2654. XOnce
  2655. X.ul "sman
  2656. Xhas found a match, that file is passed onto a text viewer for display.
  2657. XThe default viewer is
  2658. X.ul "sless,
  2659. Xbut this can be overridden by either the
  2660. X.bo "-v
  2661. Xcommand line argument
  2662. Xor the environment variable
  2663. X.bo "SmanViewer.
  2664. XIf the default viewer is not overridden, then both '+' and '@@' style
  2665. Xmatches will tell
  2666. X.ul "sless
  2667. Xto start displaying the file at the correct position.
  2668. XIf the default viewer is overridden, then all
  2669. Xfiles will be displayed at the first line.
  2670. X
  2671. X
  2672. X.SH EXAMPLES
  2673. X
  2674. XExample
  2675. X.bo "SmanPath
  2676. Xvariable:
  2677. X.in +4
  2678. X
  2679. X+AutoDocs:#?/#?.doc;@@dcc:doc/dme.refs;@@dcc:man/dme.refs;
  2680. X.br
  2681. XDOCS:.../&(.doc|.man|.txt)
  2682. X.in -4
  2683. X
  2684. X.SH ADDITION CONSIDERATIONS
  2685. X
  2686. X.ul "sman
  2687. Xwill always take the first match that it finds, so the order of the
  2688. Xrules can be used to manipulate the order of the search.
  2689. X
  2690. XAlso, '@@'
  2691. X.ul "dme.refs
  2692. Xstyle searches are the fastest.  If you have the
  2693. X.ul "autorefs
  2694. Xprogram from Matt Dillon's
  2695. X.ul "DICE
  2696. Xpackage, you are better off running this on your Autodocs, rather
  2697. Xthan using the '+' style search.
  2698. X
  2699. X.SH "SEE ALSO"
  2700. Xsless(1)
  2701. X
  2702. X.SH "BUG REPORTS"
  2703. XPlease send bug reports, comments etc. to
  2704. X.in +5
  2705. X
  2706. XJon Spencer
  2707. X
  2708. XEMail: bhgs@@gpu.utcs.utoronto.ca
  2709. X.in-5
  2710. END_OF_FILE
  2711. if test 3852 -ne `wc -c <'src/sman.n'`; then
  2712.     echo shar: \"'src/sman.n'\" unpacked with wrong size!
  2713. fi
  2714. # end of 'src/sman.n'
  2715. fi
  2716. if test -f 'src/sman_defs.h' -a "${1}" != "-c" ; then 
  2717.   echo shar: Will not clobber existing file \"'src/sman_defs.h'\"
  2718. else
  2719. echo shar: Extracting \"'src/sman_defs.h'\" \(170 characters\)
  2720. sed "s/^X//" >'src/sman_defs.h' <<'END_OF_FILE'
  2721. X
  2722. X#include <limits.h>
  2723. X
  2724. X#define VERSION "1.1"
  2725. X
  2726. X#define Prototype   extern
  2727. X
  2728. X#define MAXPATH     (200)
  2729. X#define NOT_FOUND   LONG_MIN
  2730. X#define ADOC        '+'
  2731. X#define DREF        '@'
  2732. END_OF_FILE
  2733. if test 170 -ne `wc -c <'src/sman_defs.h'`; then
  2734.     echo shar: \"'src/sman_defs.h'\" unpacked with wrong size!
  2735. fi
  2736. # end of 'src/sman_defs.h'
  2737. fi
  2738. echo shar: End of archive 1 \(of 2\).
  2739. cp /dev/null ark1isdone
  2740. MISSING=""
  2741. for I in 1 2 ; do
  2742.     if test ! -f ark${I}isdone ; then
  2743.     MISSING="${MISSING} ${I}"
  2744.     fi
  2745. done
  2746. if test "${MISSING}" = "" ; then
  2747.     echo You have unpacked both archives.
  2748.     rm -f ark[1-9]isdone
  2749. else
  2750.     echo You still need to unpack the following archives:
  2751.     echo "        " ${MISSING}
  2752. fi
  2753. ##  End of shell archive.
  2754. exit 0
  2755. -- 
  2756. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  2757. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  2758. Post requests for sources, and general discussion to comp.sys.amiga.misc.
  2759.